public async Task <int> Delete(int id) { Order ord = await db.Orders.FindAsync(id); db.Orders.Remove(ord); await db.SaveChangesAsync(); return(id); }
public async Task <int> Save(TrustTecView tecView) { TrustTec tec = tecView.Tec; tec.DatCreate = DateTime.Now; db.TrustTecs.Add(tec); await db.SaveChangesAsync(); await SaveDetail(tec.TrustTecId, tecView.Detail); return(tec.TrustTecId); }
public async Task <Order> SaveGood(int GoodID, int OrdID, decimal Quantity) { Order order = await db.Orders.FindAsync(OrdID); OrderProduct products; if (order.Step == 0) { //Значит 1е внесение products = new OrderProduct(); } else { products = await db.OrderProducts.FirstOrDefaultAsync(a => a.OrderId == OrdID); } products.GoodId = GoodID; products.OrderId = OrdID; products.Quant = Quantity; if (products.OrderProductId == 0) { db.OrderProducts.Add(products); } else { db.Entry(products).State = EntityState.Modified; } int iddet = await db.SaveChangesAsync(); return(order); }
public async Task <int> DelPerson(int id) { Person person = await db.Persons.FindAsync(id); person.IsMark = 1; db.Entry(person).State = EntityState.Modified; return(await db.SaveChangesAsync()); }
public async Task <ActionResult> DeleteConfirmed(int id) { VShip vShip = await db.VShips.FindAsync(id); db.VShips.Remove(vShip); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task <ActionResult> DelCust(int id) { //string iduser = (string)Session["usrid"]; AbzContext db = new AbzContext(); UserInCust userInCust = await db.UserInCusts.FindAsync(id); db.UserInCusts.Remove(userInCust); await db.SaveChangesAsync(); return(RedirectToAction("CustUser")); }
public async Task <OrderV> GetCopy(int id, int invoice = -1) { Order order = await CloneableOrder(id); order.DateExec = DateTime.Now.AddDays(1); if (invoice > -1) { order.Invoice = invoice; } db.Orders.Add(order); await db.SaveChangesAsync(); OrderProduct item = await db.OrderProducts.FirstOrDefaultAsync(a => a.OrderId == id); OrderProduct product = new OrderProduct(); product.GoodId = item.GoodId; product.OrderId = order.OrderId; product.Quant = item.Quant; db.OrderProducts.Add(product); await db.SaveChangesAsync(); OrderV ord = await db.OrderVs.FindAsync(order.OrderId); return(ord); }