This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0-mail.com | |
007addict.com | |
020.co.uk | |
027168.com | |
0815.ru | |
0815.su | |
0clickemail.com | |
0sg.net | |
0wnd.net | |
0wnd.org |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CategoryRepositoryADO : ICategoryRepository | |
{ | |
public async Task<IEnumerable<Category>> ListAsync() | |
{ | |
var categories = new List<Category>(); | |
using(var connection = new SqlConnection("connection_string")) | |
using(var command = new SqlCommand()) | |
{ | |
command.Connection = connection; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected override void OnModelCreating(ModelBuilder builder) | |
{ | |
base.OnModelCreating(builder); | |
builder.Entity<Category>().ToTable("Categories"); | |
builder.Entity<Category>().HasKey(p => p.Id); | |
builder.Entity<Category>().Property(p => p.Id).IsRequired().ValueGeneratedOnAdd().HasValueGenerator<InMemoryIntegerValueGenerator<int>>(); | |
builder.Entity<Category>().Property(p => p.Name).IsRequired().HasMaxLength(30); | |
builder.Entity<Category>().HasMany(p => p.Products).WithOne(p => p.Category).HasForeignKey(p => p.CategoryId); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void ConfigureServices(IServiceCollection services) | |
{ | |
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); | |
services.AddDbContext<AppDbContext>(options => | |
{ | |
options.UseInMemoryDatabase("supermarket-api-in-memory"); | |
}); | |
services.AddScoped<ICategoryRepository, CategoryRepository>(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using System.Threading.Tasks; | |
using Supermarket.API.Domain.Models; | |
using Supermarket.API.Domain.Repositories; | |
using Supermarket.API.Domain.Services; | |
namespace Supermarket.API.Services | |
{ | |
public class ProductService : IProductService | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using System.Threading.Tasks; | |
using Microsoft.EntityFrameworkCore; | |
using Supermarket.API.Domain.Models; | |
using Supermarket.API.Domain.Repositories; | |
using Supermarket.API.Persistence.Contexts; | |
namespace Supermarket.API.Persistence.Repositories | |
{ | |
public class ProductRepository : BaseRepository, IProductRepository |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using System.Threading.Tasks; | |
using Supermarket.API.Domain.Models; | |
namespace Supermarket.API.Domain.Repositories | |
{ | |
public interface IProductRepository | |
{ | |
Task<IEnumerable<Product>> ListAsync(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using System.Threading.Tasks; | |
using Supermarket.API.Domain.Models; | |
namespace Supermarket.API.Domain.Services | |
{ | |
public interface IProductService | |
{ | |
Task<IEnumerable<Product>> ListAsync(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using System.Threading.Tasks; | |
using AutoMapper; | |
using Microsoft.AspNetCore.Mvc; | |
using Supermarket.API.Domain.Models; | |
using Supermarket.API.Domain.Services; | |
using Supermarket.API.Resources; | |
namespace Supermarket.API.Controllers | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using AutoMapper; | |
using Supermarket.API.Domain.Models; | |
using Supermarket.API.Extensions; | |
using Supermarket.API.Resources; | |
namespace Supermarket.API.Mapping | |
{ | |
public class ModelToResourceProfile : Profile | |
{ | |
public ModelToResourceProfile() |
NewerOlder