public IHttpActionResult Delete(int id) { try { if (ModelState.IsValid) { int userId = UserHelper.GetCurrentUserId(); DateTime getDate = DateHelper.GetDateTime(); int result = _incomeService.Delete(id, userId, getDate); return(Ok(result)); } else { string errorResult = string.Join(" ", ModelState.Values.SelectMany(x => x.Errors).Select(x => x.ErrorMessage)); return(Content(HttpStatusCode.BadRequest, errorResult)); } } catch (Exception ex) { if (ex.InnerException == null) { return(Content(HttpStatusCode.InternalServerError, ex.Message)); } else { return(Content(HttpStatusCode.InternalServerError, ex.InnerException.Message)); } } }
public async Task <IActionResult> Delete(int incomeId) { await _authorizationService.HandleGetDeleteAsync <Income>(incomeId); await _incomeService.Delete(incomeId); return(NoContent()); }
public async Task <IActionResult> Delete(DeleteIncomeRequest request) { if (!ModelState.IsValid) { return(Failure()); } return(await _incomeService.Delete(request)); }
public async Task <IActionResult> Delete(string incomeId) { try { var userId = base.GetUserIdFromAuthorizeHeader(); await incomeService.Delete(incomeId, userId); return(Ok()); } catch (Exception ex) { return(BadRequest(ex.Message)); } }