public async Task <IActionResult> Edit(int id, [Bind("VehicleLifeEventWashId,Comment,DateTime,Timestamp,UserId,VehicleLifeEventId,VersionNumber")] VehicleLifeEventWash val) { if (val.VehicleLifeEventWashId != id) { return(NotFound()); } this.FixNullFields(val); if (ModelState.IsValid) { try { _context.Update(val); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!Exists(val.VehicleLifeEventWashId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(val)); }
private void FixNullFields(VehicleLifeEventWash val) { if (String.IsNullOrWhiteSpace(val.Comment)) { val.Comment = "N/A"; } }
public async Task <IActionResult> Create([Bind("VehicleLifeEventWashId,Comment,DateTime,Timestamp,UserId,VehicleLifeEventId,VersionNumber")] VehicleLifeEventWash val) { this.FixNullFields(val); if (ModelState.IsValid) { _context.Add(val); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(val)); }