public IActionResult Delete(long id)
        {
            var todo = GetTodoWithAuthorization(id);

            todoService.Delete(todo);
            return(NoContent());
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Delete([FromRoute] int id)
        {
            var user = await GetUser();

            var todo = await _todoService.GetById(id);

            if (todo == null)
            {
                return(BadRequest("Invalid id"));
            }

            if (user.Id != todo.User.Id)
            {
                return(Forbid());
            }

            todo = await _todoService.Delete(id);

            var response = new TodoDto()
            {
                Title       = todo.Title,
                Description = todo.Description,
                IsComplete  = todo.IsComplete,
                LastUpdate  = todo.LastUpdate
            };

            return(Ok(response));
        }
Ejemplo n.º 3
0
 private void ControlRemoveTodoTask(object sender, Controls.TodoItem.RemoveTodoTaskEventArgs e)
 {
     todoControls[e.Id].Dispose();
     todoControls.Remove(e.Id);
     _service.Delete(e.Id);
     _loggingController.Log(MessageType.information, "Removing TODO Item");
 }
Ejemplo n.º 4
0
        public JsonResult Delete(int id)
        {
            var todoModels = _todoService.GetById(id);

            _todoService.Delete(todoModels);
            return(Json(Url.Action("Index", "Todo"), JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 5
0
 public IActionResult Delete([FromRoute(Name = "id")] int id, [FromServices] ITodoService todos)
 {
     if (todos.Delete(id))
     {
         return(Ok());
     }
     return(NotFound());
 }
Ejemplo n.º 6
0
 public IActionResult Delete(int id)
 {
     if (id > 0)
     {
         var todo     = _service.Get(id);
         var services = _service.Delete(todo).GetAwaiter().GetResult();
     }
     return(Ok());
 }
Ejemplo n.º 7
0
        public IActionResult DeleteItem(string id)
        {
            var isDeleted = _todoService.Delete(id);

            if (!isDeleted)
            {
                return(NotFound());
            }

            return(NoContent());
        }
 public void Delete(int id)
 {
     try
     {
         _todoService.Delete(id);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 9
0
        public async Task <ActionResult> Delete(Guid id)
        {
            var existingItem = _service.GetById(id).Result;

            if (existingItem == null)
            {
                return(NotFound());
            }
            await _service.Delete(id);

            return(Ok());
        }
Ejemplo n.º 10
0
        public IActionResult Delete(long id)
        {
            var todo = _todoService.GetById(id);

            if (todo == null)
            {
                return(NotFound());
            }

            _todoService.Delete(todo);
            return(NoContent());
        }
Ejemplo n.º 11
0
 public IActionResult DeleteTodo(Guid id)
 {
     try
     {
         TodoService.Delete(id);
         return(NoContent());
     }
     catch (TodoNotFoundException)
     {
         return(NotFound());
     }
 }
Ejemplo n.º 12
0
        public async Task <IActionResult> DeleteTodo(int id)
        {
            var todoFromDb = await _todosService.GetProxyById(id);

            if (todoFromDb == null)
            {
                return(StatusCodeAndDtoWrapper.BuildNotFound("Specified Todo was not found"));
            }
            await _todosService.Delete(id);

            return(StatusCodeAndDtoWrapper.BuildSuccess("Todo Deleted Successfully"));
        }
Ejemplo n.º 13
0
 public ActionResult Delete(string id)
 {
     try
     {
         var todo = _todoService.GetById(Guid.Parse(id));
         _todoService.Delete(todo);
     }
     catch (Exception ex)
     {
         return(StatusCode((int)HttpStatusCode.InternalServerError, ex));
     }
     return(Ok());
 }
Ejemplo n.º 14
0
 public IActionResult Delete(int id)
 {
     if (_todoService.Delete(id))
     {
         TempData["success"] = "Task is successfully deleted!";
         return(RedirectToAction("Index"));
     }
     else
     {
         TempData["error"] = "Some error(s) accured while task delete";
         return(RedirectToAction("Index"));
     }
 }
        public TodoViewModel Delete(TodoViewModel model)
        {
            var todo = _todoService.GetById(model.Id).Result;

            _todoService.Delete(todo);

            if (Commit())
            {
                return(model);
            }

            return(null);
        }
        public IActionResult Delete(int id)
        {
            var todo = _todoService.Delete(id);

            if (todo == null)
            {
                return(NotFound(new { message = "invalid todo id" }));
            }

            var todoDto = _mapper.Map <TodoDto>(todo);

            return(Ok(todoDto));
        }
Ejemplo n.º 17
0
        public ActionResult Delete(Guid id)
        {
            try
            {
                _todoService.Delete(id);
            }
            catch (Exception)
            {
                //Catch Error on delete, such as no exist
            }

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 18
0
        public IHttpActionResult DeleteTodo(int id)
        {
            Todo todo = _service.GetById(id);

            if (todo == null)
            {
                return(NotFound());
            }

            _service.Delete(id);

            return(Ok(todo));
        }
        public async Task <HttpResponseMessage> DeleteTodo(int id)
        {
            var todo = await _todosService.Get(id);

            if (todo != null)
            {
                await _todosService.Delete(id);

                return(new HttpResponseMessage(HttpStatusCode.NoContent));
            }

            return(Request.CreateResponse(HttpStatusCode.NotFound, new ErrorDtoResponse("Todo not Found"),
                                          GlobalConfiguration.Configuration.Formatters.JsonFormatter));
        }
Ejemplo n.º 20
0
        public IActionResult Delete(DeleteTodo deleteTodo)
        {
            Todo todo = new Todo {
                ID = deleteTodo.Id
            };
            var result = _todoService.Delete(todo);

            if (result.Success)
            {
                return(Ok(result));
            }

            return(BadRequest(result));
        }
Ejemplo n.º 21
0
        public async Task <ActionResult <Todo> > Delete(string id)
        {
            if (id == null)
            {
                return(BadRequest("Id error"));
            }
            var result = await _todoService.Delete(id);

            if (result == null)
            {
                return(BadRequest("Id error"));
            }
            return(result);
        }
Ejemplo n.º 22
0
        public IActionResult Delete(int id)
        {
            var todo = _todoService.GetById(id);

            if (todo == null)
            {
                return(NotFound("Todo not exist"));
            }
            if (todo.CreatedBy != Convert.ToInt32(User.Identity.Name))
            {
                return(Forbid("You can only remove your todo"));
            }
            _todoService.Delete(id);
            return(Ok());
        }
Ejemplo n.º 23
0
 public ActionResult Delete(int id)
 {
     try
     {
         _todoService.Delete(id);
         return(NoContent());
     }
     catch (ArgumentNullException e)
     {
         return(NotFound(e));
     }
     catch (Exception e)
     {
         return(BadRequest(e));
     }
 }
Ejemplo n.º 24
0
        public async Task <IActionResult> DeleteTodo([FromRoute] int id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var todo = await _service.GetData(id);

            if (todo == null)
            {
                return(NotFound());
            }

            await _service.Delete(id);

            return(Ok(todo));
        }
        public async Task <IActionResult> DeleteTodo(int id)
        {
            var todoFromDb = await _todoService.GetProxyById(id);

            if (todoFromDb == null)
            {
                return(new NotFoundObjectResult(new
                {
                    Success = false,
                    FullMessages = new[]
                    {
                        "Not Found"
                    }
                }));
            }
            await _todoService.Delete(id);

            return(NoContent());
        }
Ejemplo n.º 26
0
        public Results.GenericResult Delete(int id)
        {
            var result = new Results.GenericResult();

            try
            {
                result.Success = appService.Delete(id);
                if (!result.Success)
                {
                    throw new Exception($"Todo {id} can't be deleted");
                }
            }
            catch (Exception ex)
            {
                Response.StatusCode = (int)HttpStatusCode.InternalServerError;
                result.Errors       = new string[] { ex.Message };
            }

            return(result);
        }
Ejemplo n.º 27
0
        public JsonResult DeleteTodo(int id)
        {
            var result = new Result();

            try
            {
                _todoService.Delete(id);
                result.Success = true;
            }
            catch (Exception x)
            {
                result.Success = false;
                result.Error   = new ErrorModel
                {
                    Code    = "Err-Excp",
                    Message = x.Message
                };
            }
            return(Json(result));
        }
Ejemplo n.º 28
0
        public IActionResult Delete(int id)
        {
            var result = new GenericResult();

            try
            {
                result.Success = appService.Delete(new TodoDto {
                    Id = id
                });
                if (!result.Success)
                {
                    throw new Exception($"Todo #{id} cant't be removed.");
                }
            }
            catch (Exception ex)
            {
                result.Errors = new string[] { ex.Message };
            }
            return(Ok(result));
        }
Ejemplo n.º 29
0
        public IActionResult Delete(int id)
        {
            var item = _todoService.GetById(id);

            if (item == null)
            {
                return(NotFound());
            }
            else
            {
                var result = _todoService.Delete(item);
                if (result > 0)
                {
                    return(new JsonResult(new { Success = true }));
                }
                else
                {
                    return(new JsonResult(new { Success = false }));
                }
            }
        }
Ejemplo n.º 30
0
        public IActionResult Delete(long id)
        {
            bool found = false;

            try
            {
                found = _todoService.Delete(id);
            }
            catch (Exception ex)
            {
                _logger.LogCritical(ex, $"Error deleting TODO item with id={id}.");
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }

            if (found)
            {
                return(NotFound());
            }

            return(NoContent());
        }