Exemple #1
0
 public void DelLabel(int id, string label)
 {
     var ctx = new ShopContext();
     var temp = ctx.Label.Where(x => x.Id == id).FirstOrDefault();
     temp.Name = label;
     ctx.SaveChanges();
 }
Exemple #2
0
 public void AddLabel(string label)
 {
     var ctx = new ShopContext();
     var temp = new Label();
     temp.Name = label;
     ctx.Label.Add(temp);
     ctx.SaveChanges();
 }
Exemple #3
0
        public bool DeleteProduct(int id)
        {
            try
            {
                var ctx = new ShopContext();
                ctx.Product.Remove(ctx.Product.Where(x => x.Id == id).FirstOrDefault());
                ctx.SaveChanges();
                return true;

            }
            catch (Exception)
            {
                return false;
            }
        }
Exemple #4
0
        public bool DelSale(int id, int count)
        {
            try
            {
                var ctx = new ShopContext();
                var temp = ctx.Product.Where(x => x.Id == id).FirstOrDefault();
                temp.Count += count;
                ctx.SaveChanges();
                return true;
            }
            catch (Exception)
            {

                return false;
            }
        }
Exemple #5
0
        public bool AddProduct(Product product, string label)
        {
            try
            {
                var ctx = new ShopContext();
                var temp = ctx.Label.Where(x => x.Name == label).SingleOrDefault();
                product.Label = temp;
                ctx.Product.Add(product);
                ctx.SaveChanges();
                return true;

            }
            catch (Exception)
            {
                return false;
            }
        }
        public bool AddSale(SaleProduct sale, string label)
        {
            try
            {
                var ctx = new ShopContext();
                var temp = ctx.Label.Where(x => x.Name == label).FirstOrDefault();
                sale.Label = temp;
                sale.Price = (sale.Price * sale.Count) - sale.Discount;
                ctx.SaleProduct.Add(sale);
                ctx.SaveChanges();
                return true;

            }
            catch (Exception)
            {

                return false;
            }
        }
Exemple #7
0
        public void ZeroCountProduct()
        {
            var ctx = new ShopContext();
            foreach (var item in ctx.Product)
            {
                item.Count = 0;

            }
            ctx.SaveChanges();
        }
Exemple #8
0
        public bool SaveProduct(Product product, string label)
        {
            try
            {
                var ctx = new ShopContext();
                var temp = ctx.Label.Where(x => x.Name == label).FirstOrDefault();
                var tempProduct = ctx.Product.Where(x => x.Id == product.Id).FirstOrDefault();
                tempProduct.Label = temp;
                tempProduct.Name = product.Name;
                tempProduct.Volume = product.Volume;
                tempProduct.Price = product.Price;
                tempProduct.Count = product.Count;
                ctx.SaveChanges();
                return true;

            }
            catch (Exception)
            {
                return false;
            }
        }