public async Task <IActionResult> Edit(int id, [Bind("RepairedModelId,Name,Type,Manufacturer," + "TechSpecification,Features")] RepairedModel repairedModel) { if (id != repairedModel.RepairedModelId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(repairedModel); await Task.Run(() => { _context.SaveChangesAsync(); _cachingModel.RefreshCache(KEY_CACHE); }); } catch (DbUpdateConcurrencyException) { if (!RepairedModelExists(repairedModel.RepairedModelId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(repairedModel)); }
public async Task <IActionResult> Edit(int id, [Bind("SparePartId,Name,Functions,Price,RepairedModelId,TypeOfFaultId")] SparePart sparePart) { if (id != sparePart.SparePartId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(sparePart); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SparePartExists(sparePart.SparePartId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["RepairedModelId"] = new SelectList(_context.RepairedModels, "RepairedModelId", "Name", sparePart.RepairedModelId); ViewData["TypeOfFaultId"] = new SelectList(_context.TypeOfFaults, "TypeOfFaultId", "Name", sparePart.TypeOfFaultId); return(View(sparePart)); }
public async Task <IActionResult> Edit(int id, [Bind("ServicedStoreId,Name,Address,PhoneNumber")] ServicedStore servicedStore) { if (id != servicedStore.ServicedStoreId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(servicedStore); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ServicedStoreExists(servicedStore.ServicedStoreId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(servicedStore)); }
public async Task <IActionResult> Edit(int id, [Bind("PostId,Name,Money")] Post post) { if (id != post.PostId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(post); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PostExists(post.PostId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(post)); }
public async Task <IActionResult> Edit(int id, [Bind("TypeOfFaultId,RepairedModelId,Name,MethodRepair,WorkPrice")] TypeOfFault typeOfFault) { if (id != typeOfFault.TypeOfFaultId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(typeOfFault); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TypeOfFaultExists(typeOfFault.TypeOfFaultId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["RepairedModelId"] = new SelectList(_context.RepairedModels, "RepairedModelId", "Name", typeOfFault.RepairedModelId); return(View(typeOfFault)); }
public async Task <IActionResult> Edit(int id, [Bind("EmployeeId,FullName,Experience,PostId")] Employee employee) { if (id != employee.EmployeeId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(employee); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EmployeeExists(employee.EmployeeId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["PostId"] = new SelectList(_context.Posts, "PostId", "Name", employee.PostId); return(View(employee)); }
public async Task <IActionResult> Edit(int id, [Bind("OrderId,DateOrder,ReturnDate,FullNameCustumer," + "RepairedModelId,TypeOfFaultId,ServicedStoreId,GuaranteeMark,GuaranteePeriod,EmployeeId")] Order order) { if (id != order.OrderId) { return(NotFound()); } if (ModelState.IsValid) { try { order.Price = (double)_context.TypeOfFaults.Where(t => t.TypeOfFaultId == order.TypeOfFaultId) .Select(t => t.WorkPrice) .FirstOrDefault(); _context.Update(order); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!OrderExists(order.OrderId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["EmployeeId"] = new SelectList(_context.Employees, "EmployeeId", "FullName", order.EmployeeId); ViewData["RepairedModelId"] = new SelectList(_context.RepairedModels, "RepairedModelId", "Name", order.RepairedModelId); ViewData["ServicedStoreId"] = new SelectList(_context.ServicedStores, "ServicedStoreId", "Name", order.ServicedStoreId); ViewData["TypeOfFaultId"] = new SelectList(_context.TypeOfFaults, "TypeOfFaultId", "Name", order.TypeOfFaultId); return(View(order)); }