public async Task <IActionResult> EditOrder(int id) { CustomerEditOrderViewModel model = new CustomerEditOrderViewModel(); //Find user var order = await orderRepository.GetById(id); mapper.Map(order, model); return(View(model)); }
public async Task <IActionResult> EditOrder(CustomerEditOrderViewModel model) { if (ModelState.IsValid) { Order order = new Order(); mapper.Map(model, order); order.OrderCargoPrice = CalculateCargoPrice(model.OrderWeight); var result = await orderRepository.Edit(order); OrderStatus orderStatus = await orderStatusRepository.GetByOrderId(model.Id); if (result && orderStatus != null) { await UpdateStatus(orderStatus, model.Status); return(RedirectToAction("Orders", "Customer", new { id = model.UserId })); } } return(View(model)); }