Exemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("EnumVehicleLifeEventTypeId,Comment,Description,Timestamp,VersionNumber")] EnumVehicleLifeEventType val)
        {
            if (val.EnumVehicleLifeEventTypeId != id)
            {
                return(NotFound());
            }

            this.FixNullFields(val);

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(val);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!Exists(val.EnumVehicleLifeEventTypeId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }

            return(View(val));
        }
Exemplo n.º 2
0
 private void FixNullFields(EnumVehicleLifeEventType val)
 {
     if (String.IsNullOrWhiteSpace(val.Comment))
     {
         val.Comment = "N/A";
     }
     if (String.IsNullOrWhiteSpace(val.Description))
     {
         val.Description = "N/A";
     }
 }
Exemplo n.º 3
0
        public async Task <IActionResult> Create([Bind("EnumVehicleLifeEventTypeId,Comment,Description,Timestamp,VersionNumber")] EnumVehicleLifeEventType val)
        {
            this.FixNullFields(val);
            if (ModelState.IsValid)
            {
                _context.Add(val);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }

            return(View(val));
        }