コード例 #1
0
        public async Task <IActionResult> Edit(RepairStatusUpdateDTO repairStatusUpdateDTO)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(View(repairStatusUpdateDTO));
                }
                RepairStatus repairStatus = new RepairStatus
                {
                    Id   = repairStatusUpdateDTO.Id,
                    Name = repairStatusUpdateDTO.Name
                };
                var result = await _repairStatusService.UpdateAsync(repairStatus);

                if (result == -1)
                {
                    ModelState.AddModelError("", "Error update");
                    return(View(repairStatusUpdateDTO));
                }
                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                return(View("Error", ex));
            }
        }
コード例 #2
0
        public async Task <IActionResult> Edit(RepairStatusUpdateDTO repairStatusUpdateDTO)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }
                RepairStatus repairStatus = new RepairStatus
                {
                    Id   = repairStatusUpdateDTO.Id,
                    Name = repairStatusUpdateDTO.Name
                };
                var result = await _repairStatusService.UpdateAsync(repairStatus);

                if (result == -1)
                {
                    return(BadRequest("Error update"));
                }
                return(Ok(repairStatus));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }