public ActionResult DeleteTask(tasks task) { user.ValidateUser(); try { taskBusiness.DeleteTask(task); var list = taskBusiness.GetTasksByIdUser(int.Parse(Session["IdUser"].ToString())); if (!list.Any()) { ModelState.AddModelError("notify", "Você ainda não possui tarefas. Adicione uma nova =)"); } return(Json(task, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(new HttpStatusCodeResult(404, ex.Message)); } }
//[System.Web.Http.HttpPost] //[ResponseType(typeof(ProjectManagerTasks))] //public IHttpActionResult AddTask(ProjectManagerTasks task) //{ // TasksBusiness taskManagerBusiness = new TasksBusiness(); // taskManagerBusiness.AddTask(task); // return CreatedAtRoute("DefaultApi", new { id = task.Task_ID }, task); //} //public void AddTask([FromBody]ProjectManagerTasks task) //{ // TasksBusiness taskManagerBusiness = new TasksBusiness(); // taskManagerBusiness.AddTask(task); //} //public List<ProjectManagerTasks> GetTasks() //{ // TasksBusiness taskManagerBusiness = new TasksBusiness(); // return taskManagerBusiness.GetTasks(); //} //public HttpResponseMessage GetTasks() //{ // TasksBusiness taskManagerBusiness = new TasksBusiness(); // List<ProjectManagerTasks> listTasks = taskManagerBusiness.GetTasks(); // return Request.CreateResponse(HttpStatusCode.OK, listTasks); //} //public JsonResult Get() //{ // JsonResult result = new JsonResult(); // result.Data = new string[] { "values1,values2" }; // result.ContentType = "text/plain"; // return result; // // return new string[] { "values1,values2" }; //} //public ProjectManagerTasks GetTaskByTaskId(int taskId) //{ // TasksBusiness taskManagerBusiness = new TasksBusiness(); // return taskManagerBusiness.GetTaskByTaskId(taskId); //} // PUT api/tasks //public void UpdateTask([FromBody]ProjectManagerTasks task) //{ // TasksBusiness taskManagerBusiness = new TasksBusiness(); // taskManagerBusiness.UpdateTask(task); //} // DELETE api/tasks/5 public void DeleteTask(int taskId) { TasksBusiness taskManagerBusiness = new TasksBusiness(); taskManagerBusiness.DeleteTask(taskId); }