示例#1
0
        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));
        }
示例#2
0
 private void FixNullFields(VehicleLifeEventWash val)
 {
     if (String.IsNullOrWhiteSpace(val.Comment))
     {
         val.Comment = "N/A";
     }
 }
示例#3
0
        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));
        }