public HttpResponseMessage Delete(HttpRequestMessage request, int id) { ThuCung modelThuCung = null; try { var listCanNang = _canNangService.GetAll(); foreach (var item in listCanNang) { if (item.IdThuCung != id) { continue; } _canNangService.GetById(item.IdCanNang); _canNangService.Delete(item.IdCanNang); } _thuCungService.SaveChange(); var listTinhTrang = _tinhTrangService.GetAll(); foreach (var item in listTinhTrang) { if (item.IdThuCung != id) { continue; } _tinhTrangService.GetById(item.IdTinhTrang); _tinhTrangService.Delete(item.IdTinhTrang); } _thuCungService.SaveChange(); modelThuCung = _thuCungService.Delete(id); if (modelThuCung != null) { Message = "Xóa thú cưng thành công"; _thuCungService.SaveChange(); } else { throw new DbEntityValidationException("Xóa thú cưng không thành công"); } } catch (DbEntityValidationException ex) { LogException(ex); } return(GetResponseMessage(IsSuccess, Message, 1, modelThuCung)); }
public HttpResponseMessage Delete(HttpRequestMessage request, int id) { TinhTrang modelTinhTrang = null; try { modelTinhTrang = _tinhTrangService.Delete(id); _tinhTrangService.SaveChange(); if (modelTinhTrang != null) { Message = "Xóa tình trạng thành công"; } else { throw new DbEntityValidationException("Xóa tình trạng không thành công"); } } catch (DbEntityValidationException ex) { LogException(ex); } return(GetResponseMessage(IsSuccess, Message, 1, modelTinhTrang)); }