Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Swastika-IO/sio.heart
✔ [ SIOH ] Swastika I/O Heart is the Special Code Base for every startup ASP.NET Core / Dotnet Core systems
https://github.com/Swastika-IO/sio.heart
dotnet-core dotnet-framework dotnet-standard mvc mvc-architecture mvc-framework
Last synced: 14 days ago
JSON representation
✔ [ SIOH ] Swastika I/O Heart is the Special Code Base for every startup ASP.NET Core / Dotnet Core systems
- Host: GitHub
- URL: https://github.com/Swastika-IO/sio.heart
- Owner: Swastika-IO
- License: gpl-3.0
- Created: 2017-07-02T05:46:59.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-09-14T05:44:54.000Z (over 2 years ago)
- Last Synced: 2025-01-17T05:12:06.253Z (14 days ago)
- Topics: dotnet-core, dotnet-framework, dotnet-standard, mvc, mvc-architecture, mvc-framework
- Language: C#
- Homepage: https://www.swastika.io
- Size: 68.2 MB
- Stars: 4
- Watchers: 4
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Swastika-Heart
[![CodeFactor](https://www.codefactor.io/repository/github/swastika-io/swastika-io-heart/badge)](https://www.codefactor.io/repository/github/swastika-io/swastika-io-heart)
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2FSwastika-IO%2FSwastika-IO-Heart.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2FSwastika-IO%2FSwastika-IO-Heart?ref=badge_shield)
[![Build Status](https://travis-ci.org/Swastika-IO/Swastika-IO-Heart.svg?branch=master)](https://travis-ci.org/Swastika-IO/Swastika-IO-Heart)## License
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2FSwastika-IO%2FSwastika-IO-Heart.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2FSwastika-IO%2FSwastika-IO-Heart?ref=badge_large)## Reference
https://github.com/Swastika-IO/Swastika-IO-Heart-Sample## Sample Code
*Create Models*```c#
using System;namespace SimpleBlog.Data.Blog
{
public class Post
{
public string Id { get; set; }
public string Title { get; set; }
public string SeoName { get; set; }
public string Excerpt { get; set; }
public string Content { get; set; }
public string Author { get; set; }
public DateTime CreatedDateUTC { get; set; }
}
}public class BlogContext : DbContext
{
public DbSet Post { get; set; }
public BlogContext()
{ }protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
if (!optionsBuilder.IsConfigured)
{
optionsBuilder.UseSqlite("Data Source=blogging.db");
//optionsBuilder.UseSqlServer("Server=(localdb)\\mssqllocaldb;Database=demo-heart.db;Trusted_Connection=True;MultipleActiveResultSets=true");}
}
}```
*Using Heart*
### Create ViewModel Class
```c#
namespace SimpleBlog.ViewModels
{
// Create ViewModel using Heart
public class PostViewModel: ViewModelBase
{
//Declare properties that this viewmodel need
public string Id { get; set; }
[Required(ErrorMessage = "Title is required")]
public string Title { get; set; }
public DateTime CreatedDateUTC { get; set; }
//Declare properties need for view or convert from model to view
public DateTime CreatedDateLocal { get { return CreatedDateUTC.ToLocalTime(); } }
public PostViewModel()
{
}public PostViewModel(Post model, BlogContext _context = null, IDbContextTransaction _transaction = null) : base(model, _context, _transaction)
{
}
}
```## Using
*Save*
```c#
var saveResult = await post.SaveModelAsync();
```
*Get Single*
```c#
var getPosts = await PostViewModel.Repository.GetSingleModelAsync(p=>p.Id==1);
return View(getPosts.Data);
```*Get All*
```c#
var getPosts = await PostViewModel.Repository.GetModelListAsync();
return View(getPosts.Data);
```*Get All with predicate*
```c#
var getPosts = await PostViewModel.Repository.GetModelListByAsync(p=>p.Title.Contains("some text"));
return View(getPosts.Data);
```*Get Paging*
```c#
var getPosts = await PostViewModel.Repository.GetModelListAsync("CreatedDate", OrderByDirection.Descending, pageSize, pageIndex);
return View(getPosts.Data);
```
*Get Paging with predicate*
```c#
var getPosts = await PostViewModel.Repository.GetModelListByAsync(p=>p.Title.Contains("some text"), "CreatedDate", OrderByDirection.Descending, pageSize, pageIndex);
return View(getPosts.Data);
```