Ejemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("EnumCritterLifeEventTypeId,Comment,DataType,Description,EnumCritterLifeEventCategoryId,FlagCantReproduce,FlagEndOfSystem,FlagIllness,Timestamp,VersionNumber")] EnumCritterLifeEventType val)
        {
            if (val.EnumCritterLifeEventTypeId != id)
            {
                return(NotFound());
            }

            this.FixNullFields(val);

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

            return(View(val));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("EnumCritterLifeEventTypeId,Comment,DataType,Description,EnumCritterLifeEventCategoryId,FlagCantReproduce,FlagEndOfSystem,FlagIllness,Timestamp,VersionNumber")] EnumCritterLifeEventType val)
        {
            this.FixNullFields(val);
            if (ModelState.IsValid)
            {
                _context.Add(val);
                await _context.SaveChangesAsync();

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

            return(View(val));
        }
Ejemplo n.º 3
0
 private void FixNullFields(EnumCritterLifeEventType val)
 {
     if (String.IsNullOrWhiteSpace(val.Comment))
     {
         val.Comment = "N/A";
     }
     if (String.IsNullOrWhiteSpace(val.DataType))
     {
         val.DataType = "N/A";
     }
     if (String.IsNullOrWhiteSpace(val.Description))
     {
         val.Description = "N/A";
     }
 }