Esempio n. 1
0
        public async Task <IActionResult> DeleteItem(int id, int listId, int itemId)
        {
            if (id != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value))
            {
                return(Unauthorized());
            }

            var userFromRepo = await _repo.GetUser(id);

            if (!userFromRepo.Lists.Any(l => l.Id == listId))
            {
                return(Unauthorized());
            }

            var listFromRepo = await _repo.GetList(listId);

            if (!listFromRepo.Items.Any(i => i.Id == itemId))
            {
                return(BadRequest());
            }

            var itemFromRepo = await _repo.GetItem(itemId);

            _repo.Delete(itemFromRepo);

            if (await _repo.SaveAll())
            {
                return(Ok());
            }

            return(BadRequest("Failed to delete the item"));
        }
Esempio n. 2
0
        public void RemoveToDo(int id)
        {
            var toDo = _toDoRepository.GetById(id);

            if (toDo != null)
            {
                _toDoRepository.Delete(toDo);
            }
        }
Esempio n. 3
0
        public ActionResult Delete(int id)
        {
            repository.Delete(id);

            return(Ok(new
            {
                status = "200",
                msg = "OK",
                obj = new { }
            }));
        }
Esempio n. 4
0
        /// <summary>
        /// This is to delete an item by id
        /// </summary>
        /// <param name="id"></param>
        /// <returns>This will retrun bool. If the todo item is deleted successfully then it will return true otherwise false. </returns>
        public async Task <bool> Delete(string id)
        {
            bool status = false;
            var  item   = await _repository.GetById(id);

            if (null != item)
            {
                return(await _repository.Delete(item));
            }
            return(status);
        }
Esempio n. 5
0
 public HttpResponseMessage Delete(int userId, int id)
 {
     if (_todoRepository.Delete(userId, id))
     {
         return(new HttpResponseMessage(HttpStatusCode.OK));
     }
     else
     {
         return(new HttpResponseMessage(HttpStatusCode.NotFound));
     }
 }
        // GET: ToDoItems/Delete/5
        public ActionResult Delete(int Id, ToDoItemVM model)
        {
            var ToDoItem = _repo.FindById(Id);
            var isSuccess = _repo.Delete(ToDoItem);
            if (!isSuccess)
            {
                return View(model);
            }
            return RedirectToAction(nameof(Index));

        }
Esempio n. 7
0
        /// <summary>
        /// This is to delete an item by id
        /// </summary>
        /// <param name="id"></param>
        /// <returns>This will retrun bool. If the todo item is deleted successfully then it will return true otherwise false. </returns>
        public bool Delete(int id)
        {
            bool status = false;
            var  item   = _repository.Find(id);

            if (null != item)
            {
                _repository.Delete(item);
                status = true;
            }
            return(status);
        }
Esempio n. 8
0
 public ActionResult Delete(int id, IFormCollection collection)
 {
     try
     {
         _toDoRepository.Delete(SessionManager.User.Id, id);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View("Error"));
     }
 }
        public IActionResult RemoveTodo(Guid id)
        {
            TodoItem item = _toDoRepository.GetSingle(id);

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

            _toDoRepository.Delete(id);

            return(NoContent());
        }
Esempio n. 10
0
 public IActionResult Delete(String id)
 {
     if (id == null)
     {
         return(BadRequest("ID must not be null"));
     }
     if (!toDoRepository.DoesItemExist(id))
     {
         return(NotFound("Item with id " + id + " was not found"));
     }
     toDoRepository.Delete(id);
     return(Ok());
 }
Esempio n. 11
0
        public async Task <IActionResult> DeletePhoto(int todoId, int id)
        {
            int UserId = int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value);

            var todo = await _repo.GetToDo(todoId, UserId);

            if (!todo.Images.Any(p => p.Id == id))
            {
                return(Unauthorized());
            }

            var photoFromRepo = await _repo.GetImage(id, UserId);


            if (photoFromRepo.PublicID != null)
            {
                var deleteParams = new DeletionParams(photoFromRepo.PublicID);

                var result = _cloudinary.Destroy(deleteParams);

                if (result.Result == "ok")
                {
                    _repo.Delete(photoFromRepo);
                }
            }

            if (photoFromRepo.PublicID == null)
            {
                _repo.Delete(photoFromRepo);
            }

            if (await _repo.SaveAll())
            {
                return(Ok());
            }

            return(BadRequest("Failed to delete the photo"));
        }
Esempio n. 12
0
        public async Task <ResultData> DeleteById(int id)
        {
            var toDo = await _repository.GetById(id);

            if (toDo == null)
            {
                return(ErrorData(EGenericErrors.No_Records_Found.GetDescription()));
            }

            await _repository.Delete(toDo);

            _unitOfWork.Commit();

            return(SuccessData(EGenericOperations.Record_Deleted_Successfully.GetDescription()));
        }
Esempio n. 13
0
        public async Task <IActionResult> DeleteTodo(int id)
        {
            int UserId = int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value);

            var todo = await _repo.GetToDo(id, UserId);

            _repo.Delete(todo);

            if (await _repo.SaveAll())
            {
                return(Ok());
            }

            return(BadRequest("Failed to delete todo"));
        }
Esempio n. 14
0
        private void Delete(object parameter)
        {
            try
            {
                _ToDoRepository.Delete(SelectedToDo);

                this.DataList     = _ToDoRepository.GetAll().ToList();
                this.SelectedToDo = null;
            }
            catch (Exception ex)
            {
                Logging.WriteLog("Fehler: " + ex.ToString());
                MessageBox.Show("Fehler: " + ex.Message);
            }
        }
Esempio n. 15
0
        // GET /todo/delete/5
        public async Task <IActionResult> Delete(int id)
        {
            // Receiving the specific item
            TodoList item = await _repo.Delete(id);

            if (item == null)
            {
                TempData["Error"] = "The item does not exist!";
            }
            else
            {
                TempData["Success"] = "The item has been deleted!";
            }

            return(RedirectToAction("Index"));
        }
Esempio n. 16
0
 public IActionResult Delete(string id)
 {
     try
     {
         var item = _toDoRepository.Find(id);
         if (item == null)
         {
             return(NotFound(ErrorCode.RecordNotFound.ToString()));
         }
         _toDoRepository.Delete(id);
     }
     catch (Exception)
     {
         return(BadRequest(ErrorCode.CouldNotDeleteItem.ToString()));
     }
     return(NoContent());
 }
Esempio n. 17
0
        public async Task <IActionResult> DeleteTask(string userName, int id)
        {
            if (userName != (User.FindFirst(ClaimTypes.Name).Value))
            {
                return(Unauthorized());
            }

            var task = await toDoRepository.getToDo(userName, id);

            if (task != null)
            {
                toDoRepository.Delete(task);
                if (await toDoRepository.SaveAll())
                {
                    return(Ok("Deleted"));
                }

                return(BadRequest());
            }

            return(NotFound());
        }
 public ActionResult Delete(int Id)
 {
     _toDoRepository.Delete(Id);
     return(RedirectToAction("Index", new { status = _status }));
 }
Esempio n. 19
0
        public async Task Delete(Guid id)
        {
            var entity = await _repo.GetById(id);

            await _repo.Delete(entity);
        }
Esempio n. 20
0
 public Task Remove(int id)
 {
     todoRepository.Delete(id);
     return(todoRepository.Save());
 }
Esempio n. 21
0
 public bool Delete(int id)
 {
     return(_repository.Delete(id));
 }
Esempio n. 22
0
 public void Delete(int id)
 {
     _toDoRepository.Delete(id);
 }
Esempio n. 23
0
        public async Task <IActionResult> Delete(int Id)
        {
            await db.Delete(Id);

            return(RedirectToAction("Index"));
        }
        public async Task <int> DeleteToDoItem(int id)
        {
            var delete_result = await _repository.Delete(id);

            return(delete_result);
        }
 public void Delete(int id)
 {
     _repository.Delete(id);
     _repository.Save();
 }
Esempio n. 26
0
 public void Delete(int id)
 {
     repo.Delete(id);
 }
Esempio n. 27
0
 public JsonResult Delete(int Id)
 {
     _toDoRepository.Delete(Id);
     return(Json(""));
 }
Esempio n. 28
0
        public Task Handle(RemoveToDoCommand message, IMessageHandlerContext context)
        {
            _toDoRepository.Delete(message.Id);

            return(Task.CompletedTask);
        }
Esempio n. 29
0
 public void DeleteTodo(int id)
 {
     _repo.Delete(id);
 }