public async Task <IActionResult> Create([Bind("Id,TypeName,NumberOfSpots,VehicleId")] VehicleType vehicleType) { if (ModelState.IsValid) { db.Add(vehicleType); await db.SaveChangesAsync(); return(RedirectToAction(nameof(CreateSuccess))); } return(View(vehicleType)); }
public async Task <IActionResult> Add(MembersAddViewModel viewmodel) { if (ModelState.IsValid) { var member = mapper.Map <Member>(viewmodel); member.MbShipRegDate = DateTime.Today; if (IsSenior(member.Personnummer)) { member.ProEndDate = DateTime.Today.AddYears(2); } else { member.ProEndDate = DateTime.Today.AddMonths(1); } db.Add(member); await db.SaveChangesAsync(); return(RedirectToAction(nameof(AddSuccess))); } return(View(viewmodel)); }