public async Task <IActionResult> Create(RepairStatusCreateDTO repairStatusCreateDTO) { try { if (!ModelState.IsValid) { return(View(repairStatusCreateDTO)); } RepairStatus repairStatus = new RepairStatus { Name = repairStatusCreateDTO.Name }; var result = await _repairStatusService.CreateAsync(repairStatus); if (result == -1) { ModelState.AddModelError("", "Error create"); return(View(repairStatusCreateDTO)); } return(RedirectToAction("Index")); } catch (Exception ex) { return(View("Error", ex)); } }
public async Task <IActionResult> Create(RepairStatusCreateDTO repairStatusCreateDTO) { try { if (ModelState.IsValid) { RepairStatus repairStatus = new RepairStatus { Name = repairStatusCreateDTO.Name }; var result = await _repairStatusService.CreateAsync(repairStatus); if (result == -1) { return(BadRequest("Error create")); } return(Ok(repairStatus)); } return(BadRequest(ModelState)); } catch (Exception ex) { return(BadRequest(ex.Message)); } }