Пример #1
0
 public static List <ShopProductsDTO> GetAllShopProducts()
 {
     using (GetCoffeeDBEntities db = new GetCoffeeDBEntities())
     {
         return(ShopProductsConverter.DALListToDTO(db.Shop_sProduct.ToList()));
     }
 }
Пример #2
0
 public static List <ShopProductsDTO> GetShopProductsById(long id)
 {
     using (GetCoffeeDBEntities db = new GetCoffeeDBEntities())
     {
         return(ShopProductsConverter.DALsToDTOs(db.Shop_sProduct.Where(Shop => Shop.shopCode == id).ToList()));
     }
 }
Пример #3
0
 public static ShopProductsDTO GetShopProductsById(long id)
 {
     using (GetCoffeeDBEntities db = new GetCoffeeDBEntities())
     {
         return(ShopProductsConverter.DALToDTO(db.Shop_sProduct.Find(id)));
     }
 }
Пример #4
0
        public static ShopProductsDTO Add(ShopProductsDTO shopProducts)
        {
            Shop_sProduct ss = ShopProductsConverter.DTOToDAL(shopProducts);

            using (GetCoffeeDBEntities db = new GetCoffeeDBEntities())
            {
                db.Shop_sProduct.Add(ss);
                db.SaveChanges();
            }
            return(ShopProductsConverter.DALToDTO(ss));
        }
Пример #5
0
 public static void updateShopProducts(List <ShopProductsDTO> shop_sProducts)
 {
     using (GetCoffeeDBEntities db = new GetCoffeeDBEntities())
     {
         List <Shop_sProduct> products = ShopProductsConverter.DTOsToDALs(shop_sProducts);
         products.ForEach(item =>
         {
             db.Entry(item).State = EntityState.Modified;
         });
         db.SaveChanges();
     }
 }