public async Task <IActionResult> Edit(EditOrderViewModel model) { if (!ModelState.IsValid) { return(View(model)); } try { var order = await _context.Orders.SingleOrDefaultAsync(m => m.OrderId == model.OrderId); order.Price = model.Price; order.Description = model.Description; order.Status = model.Status; Console.WriteLine("Website ID {0}", model.WebsiteId); order.Website = await _context.Websites.SingleOrDefaultAsync(c => c.WebsiteId == model.WebsiteId); Console.WriteLine("Website: {0}", order.Website.Domain); _context.Update(order); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!OrderExists(model.OrderId)) { return(View("NotFound")); } throw; } return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> Edit(EditWebsiteViewModel model) { if (!ModelState.IsValid) { return(View(model)); } try { var website = await _context.Websites.SingleOrDefaultAsync(m => m.WebsiteId == model.WebsiteId); website.Domain = model.Domain; website.Description = model.Description; website.CreatedAt = model.CreatedAt; _context.Update(website); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!WebsiteExists(model.WebsiteId)) { return(View("NotFound")); } throw; } return(RedirectToAction(nameof(Index))); }