public async Task <IActionResult> UpdateTask(string id, [FromBody] UpdateTaskDto updateTaskDto)
        {
            try
            {
                if (updateTaskDto == null)
                {
                    _logger.LogError("Object sent from client is null.");
                    return(BadRequest("Object is null"));
                }
                if (!ModelState.IsValid)
                {
                    _logger.LogError("Invalid object sent from client.");
                    return(BadRequest("Invalid model object"));
                }
                await _taskRepository.UpdateAsync(new TaskEntity
                {
                    RowKey       = id,
                    PartitionKey = updateTaskDto.ProjectId,
                    Name         = updateTaskDto.Name,
                    Description  = updateTaskDto.Description,
                    IsComplete   = updateTaskDto.IsComplete,
                    ETag         = "*"
                });

                return(Ok(updateTaskDto));
            }
            catch (Exception ex)
            {
                _logger.LogError($"Something went wrong inside Update action: {ex.Message}");
                return(StatusCode(500, "Internal server error"));
            }
        }
Example #2
0
        internal MyTask UpdateTask(int idl, int idt, UpdateTaskDto model)
        {
            MyTask oldTask = this.GetTask(idl, idt);

            model.MyListId = idl;
            model.MyTaskId = idt;
            if (model.Title != null)
            {
                oldTask.Title = model.Title;
            }
            if (model.Description != null)
            {
                oldTask.Description = model.Description;
            }
            if (model.DoDate != null)
            {
                oldTask.DoDate = model.DoDate;
            }
            oldTask.Done = model.Done;
            if (model.MyList != null)
            {
                oldTask.MyList = model.MyList;
            }
            db.MyTasks.Update(oldTask);
            db.SaveChanges();
            return(oldTask);
        }
Example #3
0
        public async Task <TaskDto> UpdateAsync(UpdateTaskDto updateTaskDto)
        {
            var taskEntity = await _tripFlipDbContext
                             .Tasks
                             .Include(task => task.TaskList)
                             .SingleOrDefaultAsync(task => task.Id == updateTaskDto.Id);

            EntityValidationHelper
            .ValidateEntityNotNull(taskEntity, ErrorConstants.TaskNotFound);

            // Validate current user has route 'Editor' role.
            await EntityValidationHelper.ValidateCurrentUserRouteRoleAsync(
                currentUserService : _currentUserService,
                tripFlipDbContext : _tripFlipDbContext,
                routeId : taskEntity.TaskList.RouteId,
                routeRoleToValidate : RouteRoles.Editor,
                errorMessage : ErrorConstants.NotRouteEditor);

            taskEntity.Description   = updateTaskDto.Description;
            taskEntity.PriorityLevel = _mapper.Map <Domain.Entities.Enums.TaskPriorityLevel>(updateTaskDto.PriorityLevel);
            taskEntity.IsCompleted   = updateTaskDto.IsCompleted;

            await _tripFlipDbContext.SaveChangesAsync();

            var taskDto = _mapper.Map <TaskDto>(taskEntity);

            return(taskDto);
        }
Example #4
0
        public async Task UpdateAsync_ValidTaskToUpdate_Updates()
        {
            //Arrange
            Tools.SetupCurrentUserService(_mocker);
            var sut    = CreateSut();
            var update = new UpdateTaskDto(Guid.NewGuid(), "update", true, Guid.NewGuid(), null);
            var transferServiceExtensions = Tools.SetupTransferServiceExtensions();

            var task = new Mock <ITaskEntity>();



            transferServiceExtensions.Setup(o => o.AsTaskDto(task.Object))
            .Returns(Tools.DefaultTaskDto);

            _mocker.GetMock <ITaskRepository>()
            .Setup(o => o.GetAsync(update.Id, Tools.User.Id))
            .ReturnsAsync(task.Object);

            //Act
            var result = await sut.UpdateAsync(update);

            //Assert
            result.ShouldNotBeNull();
            transferServiceExtensions.Verify(o => o.AsTaskDto(task.Object));
            task.Verify(o => o.Update(update.Name, update.IsComplete, update.GroupId, update.Deadline));
            _mocker.GetMock <ITaskRepository>()
            .Verify(o => o.UpdateAsync(task.Object));
        }
        public async Task <IActionResult> Put(UpdateTaskDto taskDto)
        {
            var taskEntity = SimpleMapper.Map <UpdateTaskDto, TaskEntity>(taskDto);

            await _taskService.UpdateAsync(taskEntity);

            return(Ok());
        }
Example #6
0
        public bool UpdateTask(UpdateTaskDto task) //Fix
        {
            var taskObj = GetTask(task.Id);

            taskObj.Description = task.Description;
            taskObj.End         = task.End;

            _db.Task.Update(taskObj);
            return(Save());
        }
Example #7
0
        public IActionResult Update(int id)
        {
            TempData["menu"] = "task";

            UpdateTaskDto updateTaskDto = _mapper.Map <UpdateTaskDto>(_taskService.GetById(id));

            ViewBag.UrgentList = new SelectList(_urgentService.GetAll(), "Id", "Definition", updateTaskDto.UrgentId);

            return(View(updateTaskDto));
        }
Example #8
0
        public IActionResult Update([FromBody] UpdateTaskDto taskDto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            _toDoTaskServices.Update(taskDto);
            return(Ok());
        }
Example #9
0
        //Update Model service, call through the Jquerry.js
        public void Update(UpdateTaskDto input)
        {
            Task update = _taskRepo.FirstOrDefault(i => i.Id == input.Id);

            update.Name        = input.Name;
            update.Description = input.Description;

            _taskRepo.UpdateAsync(update);
            //ObjectMapper.Map<UpdateTaskDto>(update);
        }
Example #10
0
        public Task UpdateTask(Guid id, UpdateTaskDto taskDto)
        {
            var task = _unitOfWork.Repository <Task>().Find(id);

            task.Title       = taskDto.Title;
            task.Description = taskDto.Description;

            _unitOfWork.Repository <Task>().Update(task);
            _unitOfWork.Complete();

            return(task);
        }
Example #11
0
 public ActionResult <MyTask> PatchMyTask(int idList, int idTask, UpdateTaskDto model)
 {
     // TODO: Your code her
     if (service.IsContainsListId(idList) && service.IsContainsTaskId(idTask))
     {
         return(Ok(service.UpdateTask(idList, idTask, model)));
     }
     else
     {
         return(NotFound());
     }
 }
Example #12
0
        public void Update(UpdateTaskDto updateTaskDto)
        {
            ToDoTask task = new ToDoTask()
            {
                Id          = updateTaskDto.Id,
                Description = updateTaskDto.Description,
                DueDate     = updateTaskDto.DueDate,
                IsCompleted = updateTaskDto.IsCompleted,
                Name        = updateTaskDto.Name
            };

            _repository.Update(task);
        }
Example #13
0
        public async Task <TaskDto> UpdateAsync(UpdateTaskDto dto)
        {
            var userId = _currentUserService.GetCurrentUser().Id;

            var task = await _taskRepository.GetAsync(dto.Id, userId);

            if (task is null)
            {
                throw new TaskIdInvalidException();
            }

            task.Update(dto.Name, dto.IsComplete, dto.GroupId, dto.Deadline);

            await _taskRepository.UpdateAsync(task);

            return(task.AsTaskDto());
        }
Example #14
0
        public IActionResult Update(UpdateTaskDto model)
        {
            if (ModelState.IsValid)
            {
                var task = _taskService.GetById(model.Id);

                task.Name        = model.Name;
                task.Description = model.Description;
                task.State       = false;
                task.UrgentId    = model.UrgentId;

                _taskService.Update(task);

                return(RedirectToAction("Index"));
            }

            ViewBag.UrgentList = new SelectList(_urgentService.GetAll(), "Id", "Definition", model.UrgentId);
            return(View(model));
        }
Example #15
0
 public void UpdateSprintTask(UpdateTaskDto updateTaskDto)
 {
     try
     {
         var task = Db.SprintTasks.Where(x => x.Id == updateTaskDto.Id).SingleOrDefault();
         task.Title       = updateTaskDto.Title;
         task.Description = updateTaskDto.Description;
         task.DeveloperId = updateTaskDto.DeveloperId;
         Db.SaveChanges();
         var developers = Db.Developers.Where(x => x.Id == updateTaskDto.DeveloperId).SingleOrDefault();
         mail.SendMail(
             developers.Email,
             developers.FirstName,
             "Task has been Created <br/>" +
             "Title : " + updateTaskDto.Title + "<br/>" +
             "Description : " + updateTaskDto.Description + "<br/>" +
             "Best luck PMS bot"
             );
     }
     catch (Exception)
     {
         throw;
     }
 }
Example #16
0
        public BaseResponse <TaskDto> Update([FromBody] UpdateTaskDto taskDto, Guid id)
        {
            var res = _taskService.UpdateTask(id, taskDto);

            return(new SuccessResponse <TaskDto>(_mapper.Map <TaskDto>(res)));
        }
Example #17
0
 public IActionResult EditTask(UpdateTaskDto updateTaskDto)
 {
     teamLeaderRepository.UpdateSprintTask(updateTaskDto);
     return(RedirectToAction("ShowSprints", new RouteValueDictionary(
                                 new { controller = "TeamLeader", action = "ShowTasks", Id = updateTaskDto.SprintId })));
 }
Example #18
0
        public async Task <IActionResult> Update([FromBody] UpdateTaskDto dto)
        {
            var task = await _taskService.UpdateAsync(dto);

            return(Ok(task));
        }
        public async System.Threading.Tasks.Task <ReadTaskDto> UpdateAsync(int id, string userId, UpdateTaskDto model)
        {
            var task = await _unitOfWork.TaskRepostitory.FindByCondition(t => t.Id == id, true)
                       .Include(t => t.Developer)
                       .Include(t => t.Project)
                       .ThenInclude(p => p.Manager)
                       .FirstAsync();

            if (task == null)
            {
                throw new TaskException($"Can't find task with id = {id}", HttpStatusCode.NotFound);
            }
            if (task.Project.ManagerId != userId)
            {
                throw new TaskException($"Don't have permission to edit this task.", HttpStatusCode.Forbidden);
            }

            var developer = await _userManager.FindByEmailAsync(model.DeveloperEmail);

            if (developer == null)
            {
                throw new TaskException($"Developer with email {model.DeveloperEmail} not found!", HttpStatusCode.NotFound);
            }
            task.Title       = model.Title;
            task.Description = model.Description;
            task.IssueDate   = model.IssueDate;
            task.DeadLine    = model.DeadLine;
            task.DeveloperId = developer.Id;
            task.StatusId    = model.StatusId;

            await _unitOfWork.SaveAsync();

            var updatedTask = await _unitOfWork.TaskRepostitory.GetTaskByIdWithDetailsAsync(id, false);

            _logger.LogInfo($"Deleted task with id = {updatedTask.Id}.");
            return(_mapper.Map <ReadTaskDto>(updatedTask));
        }
 public Task <RequestResult <TaskModel> > UpdateTaskAsync(UpdateTaskDto dto)
 {
     return(_webClient.ExecuteRequestAsync(webApi => webApi.UpdateTask(dto)));
 }