public ActionResult Edit([Bind(Include = "Id,Name,Contact,Adress,PhoneNumber,Email")] Provider provider)
 {
     if (ModelState.IsValid)
     {
         db.Entry(provider).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(provider));
 }
示例#2
0
 public ActionResult Edit([Bind(Include = "Id,Name,Contact,Position,Adress,PhoneNumber,Email,NDogovor,Description")] Client client)
 {
     if (ModelState.IsValid)
     {
         db.Entry(client).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(client));
 }
示例#3
0
 public ActionResult Edit([Bind(Include = "Id,Category,Description")] Tip tip)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tip).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tip));
 }
 public ActionResult Edit([Bind(Include = "Id,Name,Position,BDay,Adress,Phone,Email")] Employee employee)
 {
     if (ModelState.IsValid)
     {
         db.Entry(employee).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(employee));
 }
 public ActionResult Edit([Bind(Include = "Id,Mark,Price,isAvailable,Measure,ProviderId,TipId")] Product product)
 {
     if (ModelState.IsValid)
     {
         db.Entry(product).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ProviderId = new SelectList(db.Providers, "Id", "Name", product.ProviderId);
     ViewBag.TipId      = new SelectList(db.Tips, "Id", "Category", product.TipId);
     return(View(product));
 }
示例#6
0
        private void SaleDelete(Sale sale)
        {
            var greenhousesForSale = _db.GreenhouseForSales
                                     .Include(g => g.Sale)
                                     .Where(g => g.Sale.Id == sale.Id).ToList();

            if (sale.Shipment == true)
            {
                foreach (var g in greenhousesForSale)
                {
                    Greenhouse g1 = _db.Greenhouses
                                    .Include(gh => gh.PacksForGH)
                                    .Include(gh => gh.Stock)
                                    .FirstOrDefault(gh => gh.Name == g.Name && gh.Stock.Id == sale.Stock.Id);

                    foreach (var p in g1.PacksForGH)
                    {
                        Pack p1 = _db.Packs
                                  .Include(pck => pck.Stock)
                                  .FirstOrDefault(pck => pck.Name == p.Name && pck.Stock.Id == sale.Stock.Id);
                        p1.Amount += 1 * p.Amount * g.Amount;

                        //хуй знает нужно или нет, чтобы сохранялась в историю при удалении сэйла, потестить

                        /* HistoryPack hp1 = new HistoryPack()
                         * {
                         *   Name = p1.Name,
                         *   Amount = p.Amount * g.Amount * 1,
                         *   Date = DateTime.Now,
                         *   ForHistory = false,
                         *   Sale = null,
                         *   Pack = p1,
                         *   Stock = sale.Stock,
                         *   Description = sale.Number
                         * };
                         * _db.HistoryPacks.Add(hp1);*/
                    }
                }
            }

            foreach (var greenhouseForSale in greenhousesForSale)
            {
                greenhouseForSale.Stock            = null;
                greenhouseForSale.Stock            = null;
                greenhouseForSale.Claim            = null;
                _db.Entry(greenhouseForSale).State = EntityState.Modified;
                _db.GreenhouseForSales.Remove(greenhouseForSale);
            }

            var historyPacks = _db.HistoryPacks
                               .Include(h => h.Sale)
                               .Where(h => h.Sale.Id == sale.Id).ToList();

            foreach (var historyPack in historyPacks)
            {
                historyPack.Stock            = null;
                historyPack.Sale             = null;
                historyPack.Pack             = null;
                _db.Entry(historyPack).State = EntityState.Modified;
                _db.HistoryPacks.Remove(historyPack);
            }

            var infoMoneys = _db.InfoMoneys
                             .Include(i => i.Sale)
                             .Where(i => i.Sale.Id == sale.Id).ToList();

            foreach (var infoMoney in infoMoneys)
            {
                infoMoney.Sale             = null;
                infoMoney.Stock            = null;
                infoMoney.Dealer           = null;
                _db.Entry(infoMoney).State = EntityState.Modified;
                _db.InfoMoneys.Remove(infoMoney);
            }

            var installments = _db.Installments
                               .Include(i => i.Sale)
                               .Where(i => i.Sale.Id == sale.Id).ToList();

            foreach (var installment in installments)
            {
                installment.Sale             = null;
                _db.Entry(installment).State = EntityState.Modified;
                _db.Installments.Remove(installment);
            }
            _db.Sales.Remove(sale);
        }