public async Task <IActionResult> Edit(int id, [Bind("VehicleTrailerMapId,Comment,Timestamp,TrailerId,VehicleMainId,VersionNumber")] VehicleTrailerMap val)
        {
            if (val.VehicleTrailerMapId != id)
            {
                return(NotFound());
            }

            this.FixNullFields(val);

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(val);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!Exists(val.VehicleTrailerMapId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["TrailerId"]     = new SelectList(_context.Vehicle, "VehicleId", "Name", val.TrailerId);
            ViewData["VehicleMainId"] = new SelectList(_context.Vehicle, "VehicleId", "Name", val.VehicleMainId);
            return(View(val));
        }
 private void FixNullFields(VehicleTrailerMap val)
 {
     if (String.IsNullOrWhiteSpace(val.Comment))
     {
         val.Comment = "N/A";
     }
 }
        public async Task <IActionResult> Create([Bind("VehicleTrailerMapId,Comment,Timestamp,TrailerId,VehicleMainId,VersionNumber")] VehicleTrailerMap val)
        {
            this.FixNullFields(val);
            if (ModelState.IsValid)
            {
                _context.Add(val);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["TrailerId"]     = new SelectList(_context.Vehicle, "VehicleId", "Name", val.TrailerId);
            ViewData["VehicleMainId"] = new SelectList(_context.Vehicle, "VehicleId", "Name", val.VehicleMainId);
            return(View(val));
        }