예제 #1
0
        public ShopMobilesM Save(ShopMobilesM shopMobiles)
        {
            Shop_Mobiles shopMobilesDb = new Shop_Mobiles()
            {
                MobileId    = shopMobiles.MobileId,
                MobilesLeft = shopMobiles.MobilesLeft,
                ShopId      = shopMobiles.ShopId,
                Price       = shopMobiles.Price,
            };

            Context.Shop_Mobiles.Add(shopMobilesDb);
            Context.SaveChanges();
            shopMobiles.Id = shopMobilesDb.Id;
            return(shopMobiles);
        }
예제 #2
0
        public ShopMobilesM Delete(int id)
        {
            Shop_Mobiles shopMobiles = Context.Shop_Mobiles.SingleOrDefault(x => x.Id == id);

            Context.Shop_Mobiles.Remove(shopMobiles);
            Context.SaveChanges();

            return(new ShopMobilesM()
            {
                Id = shopMobiles.Id,
                MobileId = shopMobiles.MobileId ?? -1,
                MobilesLeft = shopMobiles.MobilesLeft ?? 0,
                ShopId = shopMobiles.ShopId ?? -1,
                Price = shopMobiles.Price ?? 0,
            });
        }
예제 #3
0
        public ShopMobilesM FindById(int id)
        {
            Shop_Mobiles shopMobiles = Context.Shop_Mobiles.SingleOrDefault(x => x.Id == id);

            if (shopMobiles == null)
            {
                return(null);
            }

            return(new ShopMobilesM()
            {
                Id = shopMobiles.Id,
                MobileId = shopMobiles.MobileId ?? -1,
                MobilesLeft = shopMobiles.MobilesLeft ?? 0,
                ShopId = shopMobiles.ShopId ?? -1,
                Price = shopMobiles.Price ?? 0,
            });
        }