Ejemplo n.º 1
0
        public async Task <ActionResult> Remove(string id)
        {
            var isDeleted = await _taskItemRepository.Delete(id);

            if (isDeleted)
            {
                return(Ok());
            }
            return(NotFound());
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Delete(int id)
        {
            await _repository.Delete(id);

            return(Ok(await _repository.GetAll()));
        }
Ejemplo n.º 3
0
 public void DeleteTask(int id)
 {
     repository.Delete(id);
 }
Ejemplo n.º 4
0
        public async Task <IHttpActionResult> Delete(Guid id)
        {
            await _taskRepository.Delete(id);

            return(Ok());
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Deletes a Task Item from the application
        /// </summary>
        /// <param name="input">
        /// Holds the input necessary for deleting a TaskItem
        /// </param>
        /// <returns>
        /// The result of deleting the TaskItem
        /// </returns>
        public DeleteTaskUseCaseOutput Execute(DeleteTaskUseCaseInput input)
        {
            Guid idToDelete = input.Id;

            ITaskItemRepository taskRepo = taskItemRepositoryFactory.New();

            //retrieve task item to delete
            Maybe <TaskItemDAL> maybeTask = taskRepo.GetById(idToDelete);

            if (maybeTask.HasValue)
            {
                TaskItemDAL taskToDelete = maybeTask.Value;

                //delete task item from repository
                if (taskRepo.Delete(idToDelete) == false)
                {
                    //unable to delete task
                    return(new DeleteTaskUseCaseOutput()
                    {
                        Error = "Unable to to delete TaskItem", Success = false
                    });
                }

                //delete task item from domain
                if (taskItemManager.Remove(idToDelete) == false)
                {
                    //failed to remove TaskItem from domain
                    //TODO : handle this appropriately
                    return(new DeleteTaskUseCaseOutput()
                    {
                        Error = "Unable to to delete TaskItem", Success = false
                    });
                }

                INotificationRepository notificationRepo = notificationRepositoryFactory.New();

                //iterate through notifications in repository and delete those generated by the deleted task
                foreach (NotificationDAL notificationDAL in notificationRepo.GetAll())
                {
                    if (notificationDAL.taskId == idToDelete)
                    {
                        if (notificationRepo.Delete(notificationDAL) == false)
                        {
                            //unable to delete notification
                            //TODO : handle this appropriately
                        }
                    }
                }

                //delete task notifications in domain
                if (notificationManager.Remove(idToDelete) == false)
                {
                    //failed to remove task notifications from domain
                    //TODO : handle this appropriately
                }

                notificationRepo.Save();
                taskRepo.Save();
            }
            else
            {
                return(new DeleteTaskUseCaseOutput()
                {
                    Error = "Unable to find TaskItem to delete", Success = false
                });
            }

            return(new DeleteTaskUseCaseOutput()
            {
                Success = true
            });
        }