public IHttpActionResult Post(TruckViewModel truck) { _truckService.CreateTruck(truck); _maintenancePlanDetailService.UpdatePlan(truck.MaintenanceItems, "0", truck.TruckC); _inspectionPlanDetailService.Add(truck.Inspection, "0", truck.TruckC); return(Ok()); }
public async Task CreateTruck([FromBody] TruckModel model) { await _truckService.CreateTruck(new Trucks { Height = model.Height, Width = model.Width, Number = model.Number }); }
public async Task <IActionResult> Save(SaveTruckDTO dto) { var models = await _modelService.ListModels(); models = models ?? new List <ModelDTO>(); ViewData["ModelId"] = new SelectList(models, "Id", "Name"); if (ModelState.IsValid) { if (dto.Id.HasValue) { var edited = await _truckService.EditTruck(dto); return(await ViewAsync(edited, "Truck", "Index")); } else { var truck = await _truckService.CreateTruck(dto); return(await ViewAsync(truck, "Truck", "Index")); } } return(View()); }