public async Task <IActionResult> Edit(int id, [Bind("Id,FirstName,LastName,Personnummer,MbShipRegDate,ProEndDate")] Member member) { if (id != member.Id) { return(NotFound()); } if (ModelState.IsValid) { try { db.Update(member); db.Entry(member).Property(x => x.MbShipRegDate).IsModified = false; db.Entry(member).Property(x => x.ProEndDate).IsModified = false; await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MemberExists(member.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(SuccessEdit))); } return(View(member)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Brand,Model,Color,RegNr,NumberOfwheeels,ArrivalTime,VehicleTypeId,MemberId")] Vehicle vehicle) { if (id != vehicle.Id) { return(NotFound()); } if (ModelState.IsValid) { try { db.Update(vehicle); db.Entry(vehicle).Property(x => x.ArrivalTime).IsModified = false; await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!VehicleExists(vehicle.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(EditSuccess))); } // not needed anymore, changed in view //ViewData["MemberId"] = new SelectList(db.Set<Member>(), "Id", "FirstName", vehicle.MemberId); //ViewData["VehicleTypeId"] = new SelectList(db.Set<VehicleType>(), "Id", "Id", vehicle.VehicleTypeId); return(View(vehicle)); }