Ejemplo n.º 1
0
 public async Task <IActionResult> Edit(byte id, [Bind("ConditionId,Condition")] TireCondition tireCondition)
 {
     if (id != tireCondition.ConditionId)
     {
         return(NotFound());
     }
     if (IsTireConditionForUpdate(tireCondition.Condition, tireCondition.ConditionId))
     {
         ModelState.AddModelError("Condition", "The tire condition is already exist.");
     }
     if (ModelState.IsValid)
     {
         try
         {
             _context.Update(tireCondition);
             await _context.SaveChangesAsync();
         }
         catch (DbUpdateConcurrencyException)
         {
             if (!TireConditionExists(tireCondition.ConditionId))
             {
                 return(NotFound());
             }
             else
             {
                 throw;
             }
         }
         return(RedirectToAction(nameof(Index)));
     }
     return(View(tireCondition));
 }
Ejemplo n.º 2
0
        public async Task <IActionResult> Edit(byte id, [Bind("TypeId,TypeName")] VehicleType vehicleType)
        {
            if (id != vehicleType.TypeId)
            {
                return(NotFound());
            }
            if (IsTypeNameForUpdate(vehicleType.TypeName, vehicleType.TypeId))
            {
                ModelState.AddModelError("TypeName", "The vehicle type name is already exist.");
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(vehicleType);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!VehicleTypeExists(vehicleType.TypeId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(vehicleType));
        }
Ejemplo n.º 3
0
 public async Task <IActionResult> Edit(int id, [Bind("Vid,TypeId,FuelLevel,Idnumber,ConditionId,TireQty")] Vehicle vehicle)
 {
     if (id != vehicle.Vid)
     {
         return(NotFound());
     }
     if (IsVehicleExistforUpdate(vehicle.Idnumber, vehicle.Vid))
     {
         ModelState.AddModelError("Idnumber", "The VIN/HIN is already exists.");
     }
     if (ModelState.IsValid)
     {
         try
         {
             _context.Update(vehicle);
             await _context.SaveChangesAsync();
         }
         catch (DbUpdateConcurrencyException)
         {
             if (!VehicleExists(vehicle.Vid))
             {
                 return(NotFound());
             }
             else
             {
                 throw;
             }
         }
         return(RedirectToAction(nameof(Index)));
     }
     ViewData["ConditionId"] = new SelectList(_context.TireCondition, "ConditionId", "Condition", vehicle.ConditionId);
     ViewData["TypeId"]      = new SelectList(_context.VehicleType, "TypeId", "TypeName", vehicle.TypeId);
     return(View(vehicle));
 }