public async Task <IActionResult> Edit(int id, Order order) { if (id != order.Id) { return(NotFound()); } if (ModelState.IsValid) { order.UserId = _userManager.GetUserId(User); order.UserName = _userManager.GetUserAsync(User).Result.Name; var today = DateTime.UtcNow.Date; order.Date = new DateTime(today.Year, today.Month + 1, today.Day); order.Amount = order.Mb + order.M46 + order.M62 + order.MAb + order.MA46 + order.MA62 + order.MTRb + order.MTR46 + order.MTR62 + order.MTb + order.MT46 + order.MT62; order.Cost = order.Mb * MbPrice + order.M46 * M46Price + order.M62 * M62Price + order.MAb * MAbPrice + order.MA46 * MA46Price + order.MA62 * MA62Price + order.MTRb * MTRbPrice + order.MTR46 * MTR46Price + order.MTR62 * MTR62Price + order.MTb * MTbPrice + order.MT46 * MT46Price + order.MT62 * MT62Price; _ordersStorage.Update(order); await _ordersStorage.SaveChangesAsync(); return(RedirectToAction(nameof(GetByUser))); } return(View(order)); }
public RedirectToActionResult Update(Orders model) { _storage.Update(model); return(RedirectToAction("List", "Orders")); }