public async Task <IActionResult> PutAccounting([FromRoute] int id, [FromBody] Accounting accounting) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != accounting.Id) { return(BadRequest()); } _context.Entry(accounting).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AccountingExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public ActionResult Edit([Bind(Include = "CountryID,CountryName")] Country country) { if (ModelState.IsValid) { db.Entry(country).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(country)); }
public ActionResult Edit([Bind(Include = "SupplierID,SupplierName,OwnerID")] Supplier supplier) { if (ModelState.IsValid) { db.Entry(supplier).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.OwnerID = new SelectList(db.OwnerCompanies, "OwnerID", "Owner", supplier.OwnerID); return(View(supplier)); }
public ActionResult Edit([Bind(Include = "CustomerID,ContactName,CompanyName,Address,StateID,City,DateAdded,Email,Phone")] Customer customer) { if (ModelState.IsValid) { db.Entry(customer).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.StateID = new SelectList(db.States, "StateID", "StateName", customer.StateID); return(View(customer)); }
public ActionResult Edit([Bind(Include = "StateID,StateName,CountryID")] State state) { if (ModelState.IsValid) { db.Entry(state).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CountryID = new SelectList(db.Countries, "CountryID", "CountryName", state.CountryID); return(View(state)); }
public ActionResult Edit([Bind(Include = "CategoryID,CategoryName,OwnerID")] Category category) { if (ModelState.IsValid) { db.Entry(category).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.OwnerID = new SelectList(db.OwnerCompanies, "OwnerID", "Owner", category.OwnerID); return(View(category)); }
public void Update(Domain.Day day) { var entity = EntityFrom(day); var existingEntity = context.Days.FirstOrDefault(e => e.Date == entity.Date) ?? throw new ArgumentException($"The day {entity.Date} was not found"); logger.Log(context, "Day", "Update", existingEntity, entity); context.Entry(existingEntity).CurrentValues.SetValues(entity); context.SaveChanges(); }
public ActionResult Edit([Bind(Include = "OrderID,OrderDate,RequiredDate,Ordered,CustomerID,EmployeeID")] Order order) { if (ModelState.IsValid) { db.Entry(order).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CustomerID = new SelectList(db.Customers, "CustomerID", "CompanyName", order.CustomerID); ViewBag.EmployeeID = new SelectList(db.Employees, "EmployeeID", "FirstName", order.EmployeeID); return(View(order)); }
public ActionResult Edit([Bind(Include = "ProductID,ProductName,QuantityPerUnit,UnitPrice,UnitInStock,UnitInOrder,ReorderLevel,ProductDescription,Remarks,CategoryID,SupplierID,OwnerID")] Product product) { if (ModelState.IsValid) { db.Entry(product).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CategoryID = new SelectList(db.Categories, "CategoryID", "CategoryName", product.CategoryID); ViewBag.OwnerID = new SelectList(db.OwnerCompanies, "OwnerID", "Owner", product.OwnerID); ViewBag.SupplierID = new SelectList(db.Suppliers, "SupplierID", "SupplierName", product.SupplierID); return(View(product)); }
public void Update(Domain.DaySlip item) { var entity = EntityFrom(item); var existingEntity = context.Slips .Include(e => e.Payments) .FirstOrDefault(e => e.Id == entity.Id) ?? throw new ArgumentException($"The dayslip {entity.Id} was not found"); logger.Log(context, "DaySlip", "Update", existingEntity, entity); context.Entry(existingEntity).CurrentValues.SetValues(entity); existingEntity.Payments.Clear(); context.SaveChanges(); }
public ActionResult Edit([Bind(Include = "EmployeeID,FirstName,Lastname,DOB,HireDate,Address,Email,Phone,PhotoPath,CityID")] Employee employee) { if (ModelState.IsValid) { db.Entry(employee).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } else { return(Content("invalid model")); } //ViewBag.CityID = new SelectList(db.Cities, "CityID", "CityName", employee.CityID); //return View(employee); }
public Task UpdateAsync(Account item) => Task.FromResult(accountingContext.Entry(item).State = EntityState.Modified);
public void UpdateDoc(AccountingDocument inputData) { _context.Entry(inputData).OriginalValues["RowVersion"] = inputData.RowVersion; _context.AccountingDocumentSet.Update(inputData); _context.SaveChanges(); }