예제 #1
0
 public bool Add(Costumer model)
 {
     try
     {
         _costumerDbContext.Add(model);
         _costumerDbContext.SaveChanges();
     }
     catch (System.Exception)
     {
         return(false);
     }
     return(true);
 }
예제 #2
0
        public bool Add(Invoice model)
        {
            try
            {
                _costumerDbContext.Add(model);
                _costumerDbContext.SaveChanges();

                var id = model.InvoiceId;

                (from d in _costumerDbContext.InvoiceDetail
                 where d.InvoiceId == 0
                 select d).ToList().ForEach(x => x.InvoiceId = id);

                _costumerDbContext.SaveChanges();
            }

            catch (System.Exception)
            {
                return(false);
            }
            return(true);
        }
예제 #3
0
        public bool Add(InvoiceDetail model)
        {
            try
            {
                _costumerDbContext.Add(model);
                _costumerDbContext.SaveChanges();

                var id       = model.ProductId;
                var quantity = model.Quantity;

                (from p in _costumerDbContext.Product
                 where p.ProductId == id
                 select p).ToList().ForEach(x => x.Quantity = (x.Quantity - quantity));

                _costumerDbContext.SaveChanges();
            }
            catch (System.Exception)
            {
                return(false);
            }
            return(true);
        }