public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Mobile")] Mechanic mechanic) { if (id != mechanic.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(mechanic); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MechanicExists(mechanic.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(mechanic)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Part,Cost")] VehiclePart vehiclePart) { if (id != vehiclePart.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(vehiclePart); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!VehiclePartExists(vehiclePart.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(vehiclePart)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,StatusBookingId,VehicleTypeId,TypeOfBookingId,VehicleLicense,VehicleEngine,Comments,DateTime, VehicleStyle, Engine, Cost", "VehicleId", "Mechanics", "VehicleParts", "VehiclePartsId", "MechanicsIds", "VehiclePartsIds")] Booking booking) { if (id != booking.Id) { return(NotFound()); } if (ModelState.IsValid) { try { booking.Mechanics = new List <MechanicBooking>(); booking.VehicleParts = new List <VehiclePartBooking>(); CleanOldValues(booking.Id); foreach (int mechanicId in booking.MechanicsIds) { booking.Mechanics.Add(new MechanicBooking() { MechanicId = mechanicId }); } foreach (int vehiclePartId in booking.VehiclePartsIds) { booking.VehicleParts.Add(new VehiclePartBooking() { VehiclePartId = vehiclePartId }); } if (OverDailyLimit(booking.DateTime)) { return(RedirectToAction(nameof(Edit), new { dailyLimit = true })); } else if (IsSunday(booking.DateTime)) { return(RedirectToAction(nameof(Edit), new { sunday = true })); } _context.Update(booking); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BookingExists(booking.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(booking)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Email,Password,ConfirmPassword,MobilePhone")] User user) { if (id != user.Id) { return(NotFound()); } if (ModelState.IsValid) { try { user.Level = Models.Enum.UserLevel.Normal; _context.Update(user); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { throw; } return(RedirectToAction(nameof(Index))); } return(View(user)); }