public RepositoryBase(LNBagShopDBEntities context) { _context = context; var config = new MapperConfiguration(cfg => { cfg.AddProfile(new MappingProfile()); }); Mapper = config.CreateMapper(); }
public DTO.Category GetCategory(int id) { using (var db = new LNBagShopDBEntities()) { var config = new MapperConfiguration(cfg => { cfg.AddProfile(new MappingProfile()); }); var mapper = config.CreateMapper(); return(mapper.Map <DataAccessLayer.Category, DTO.Category>(db.Categories.Find(id))); } }
public DTO.Product Add(DataAccessLayer.Product product) { using (var db = new LNBagShopDBEntities()) { var returnEntity = db.Products.Add(product); var config = new MapperConfiguration(cfg => { cfg.AddProfile(new MappingProfile()); }); var mapper = config.CreateMapper(); var return1 = mapper.Map <DataAccessLayer.Product, DTO.Product>(returnEntity); db.SaveChanges(); return(return1); } }
public IEnumerable <DTO.Category> GetCategories() { List <DTO.Category> categories = new List <DTO.Category>(); using (var db = new LNBagShopDBEntities()) { var config = new MapperConfiguration(cfg => { cfg.AddProfile(new MappingProfile()); }); var mapper = config.CreateMapper(); foreach (DataAccessLayer.Category category in db.Categories.ToList()) { categories.Add(mapper.Map <DataAccessLayer.Category, DTO.Category>(category)); } return(categories); } }
public DTO.Product GetProduct(int id) { using (var db = new LNBagShopDBEntities()) { DTO.Product product = null; DataAccessLayer.Product dbProduct = db.Products.Find(id); if (dbProduct != null) { var config = new MapperConfiguration(cfg => { cfg.AddProfile(new MappingProfile()); }); var mapper = config.CreateMapper(); product = mapper.Map <DataAccessLayer.Product, DTO.Product>(dbProduct); } return(product); } }
public List <DTO.Product> GetProducts() { List <DTO.Product> products = new List <DTO.Product>(); using (var db = new LNBagShopDBEntities()) { var config = new MapperConfiguration(cfg => { cfg.AddProfile(new MappingProfile()); }); var mapper = config.CreateMapper(); foreach (DataAccessLayer.Product product in db.Products.ToList()) { products.Add(mapper.Map <DataAccessLayer.Product, DTO.Product>(product)); } return(products); } }
public CategoriesRepository(LNBagShopDBEntities context) : base(context) { }
public OrderDetailsRepository(LNBagShopDBEntities context) : base(context) { }
public ProductsRepository(LNBagShopDBEntities context) : base(context) { }
public UnitOfWork(LNBagShopDBEntities context) { _context = context; }