public async Task <IActionResult> DeleteUnitTemp(int DriverId, int TruckId, int id) { UnitTemp item = _context.UnitTemps.Find(id); if (item == null) { return(NotFound()); } _context.UnitTemps.Remove(item); await _context.SaveChangesAsync(); return(RedirectToAction($"{DriverId}/{nameof(Index)}/{TruckId}")); }
public IActionResult AddUnitTemp(UnitTempViewModel model) { if (ModelState.IsValid) { UnitTemp temp = new UnitTemp { Buy = model.Buy, EndLts = model.EndLts, EndPulg = model.EndPulg, Fuel = model.Fuel, Id = 0, StartLts = model.StartLts, StartPulg = model.StartPulg }; switch (model.Fuel) { case "1": temp.TypeFuel = TypeFuel.Regular; break; case "0": temp.TypeFuel = TypeFuel.Diesel; break; case "2": temp.TypeFuel = TypeFuel.Super; break; case "3": temp.TypeFuel = TypeFuel.Exonerado; break; } _context.UnitTemps.Add(temp); _context.SaveChanges(); return(RedirectToAction($"{model.DriverId}/{nameof(Index)}/{model.TruckId}")); } return(View(model)); }