public IActionResult Delete(int id) { if (!ModelState.IsValid) { return(new BadRequestObjectResult(ModelState)); } _wardService.Delete(id); _wardService.Save(); return(new OkObjectResult(id)); }
public async Task <BaseResult> Delete(int districtId) { var rs = new BaseResult() { Result = Result.Success }; if (districtId > 0) { var district = _districtRepository.Query() .Include(d => d.Wards) .FirstOrDefault(d => d.Id == districtId); if (district != null) { district.IsDeleted = true; var wards = _wardRepository.Query() .Include(w => w.District) .Where(w => w.ParentId == districtId) .ToList(); foreach (Ward w in wards) { await _wardService.Delete(w.Id); } _districtRepository.Update(district); try { _districtRepository.SaveChange(); } catch (Exception ex) { rs.Result = Result.SystemError; rs.Message = ex.ToString(); } } else { rs.Message = "Không tìm thấy huyện / quận yêu cầu!"; rs.Result = Result.Failed; } } else { rs.Message = "Mã huyện / quận không hợp lệ!"; rs.Result = Result.Failed; } return(rs); }
public async Task <ActionResult <WardDetail_WardDTO> > Delete([FromBody] WardDetail_WardDTO WardDetail_WardDTO) { if (!ModelState.IsValid) { throw new MessageException(ModelState); } Ward Ward = ConvertDTOToEntity(WardDetail_WardDTO); Ward = await WardService.Delete(Ward); WardDetail_WardDTO = new WardDetail_WardDTO(Ward); if (Ward.IsValidated) { return(WardDetail_WardDTO); } else { return(BadRequest(WardDetail_WardDTO)); } }
public async Task <ResponseModel> Delete([FromBody] WardModel model) { var response = await _wardService.Delete(model); return(response); }
public async Task <IActionResult> Delete(int id) { var result = await _wardService.Delete(id); return(Ok(result)); }