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));
            }
        }
Example #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));
            }
        }
        public IActionResult Edit(RepairStatus repairStatus)
        {
            var model = new RepairStatusUpdateDTO
            {
                Id   = repairStatus.Id,
                Name = repairStatus.Name
            };

            return(View(model));
        }