public JsonResult Delete(int id) { var result = new TaskResult(); try { var job = _jobsService.GetById(id); if (job == null) { result.AddErrorMessage("No puedes eliminar un puesto que no existe."); } else if (job.UserId == _currentUser.UserId) { if (!job.IsActive) { result.AddErrorMessage("El puesto que intentas eliminar ya está eliminado."); } else { result = _jobsService.Delete(job); } } else { result.AddErrorMessage("No puedes eliminar un puesto que no creaste."); } } catch (Exception ex) { HttpContext.RiseError(ex); result.AddErrorMessage(ex.Message); } return(Json(result)); }
public async Task <IActionResult> Delete([FromQuery][Required] int jobId) { if (await _jobsService.Delete(jobId) == EntityState.Deleted) { return(Ok()); } return(NoContent()); }
public HttpResponseMessage Delete(int id) { if (!ModelState.IsValid) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } jobsService.Delete(id); return(Request.CreateResponse(HttpStatusCode.OK, "Deleted")); }
public async Task <ActionResult> Delete(long id) { var deleted = await _service.Delete(id, _currentUserService.GetId()); if (!deleted) { return(BadRequest()); } return(Ok()); }