Example #1
0
        public RepositoryBase(LNBagShopDBEntities context)
        {
            _context = context;
            var config = new MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new MappingProfile());
            });

            Mapper = config.CreateMapper();
        }
Example #2
0
 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)));
     }
 }
Example #3
0
 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);
     }
 }
Example #4
0
        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);
            }
        }
Example #5
0
 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);
     }
 }
Example #6
0
        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);
            }
        }
Example #7
0
 public CategoriesRepository(LNBagShopDBEntities context) : base(context)
 {
 }
 public OrderDetailsRepository(LNBagShopDBEntities context) : base(context)
 {
 }
Example #9
0
 public ProductsRepository(LNBagShopDBEntities context) : base(context)
 {
 }
Example #10
0
 public UnitOfWork(LNBagShopDBEntities context)
 {
     _context = context;
 }