public async Task <IActionResult> Delete(string IdSize) { var affectedResult = await _sizeService.DeleteSize(IdSize); if (affectedResult == 0) { return(BadRequest()); } return(Ok()); }
public IActionResult Delete(int id) { try { _sizeService.DeleteSize(id); return(Ok()); } catch (Exception ex) { return(BadRequest("Size not found")); } }
public ActionResult <SizeDto> DeleteSize(int id) { var sizeDto = _sizeService.DeleteSize(id); if (sizeDto == null) { List <string> errorMessage = new List <string>(); errorMessage.Add("Đã phát sinh lỗi, vui lòng thử lại"); return(BadRequest(new ResponseDto(errorMessage, 500, ""))); } List <string> successMessage = new List <string>(); successMessage.Add("Xoá thành công"); var responseDto = new ResponseDto(successMessage, 200, ""); return(Ok(responseDto)); }
public IActionResult DeleteSize(int id) { try { Size size = _sizeService.GetSizeById(id); if (size.IsEntityNull()) { _logger.Error($"Size with id: {id} not found in db"); return(NotFound()); } _sizeService.DeleteSize(size); _sizeService.Save(); return(NoContent()); } catch (Exception ex) { _logger.Error(ex, "Error in call : api/size/DeleteSize/" + id); return(StatusCode(StatusCodes.Status500InternalServerError, "Internal server error")); } }