public void EditTask(EditTaskDto editSprint)
        {
            var task = db.SprintTasks.Where(x => x.Id == editSprint.Id).SingleOrDefault();

            task.Title       = editSprint.Title;
            task.Description = editSprint.Description;
            db.SaveChanges();
        }
        public async Task <bool> EditTask(EditTaskDto task)
        {
            var entity = await taskRepository.GetSingleByCondition(x => x.TaskId == task.TaskId);

            if (entity == null)
            {
                return(false);
            }

            var updated = mapper.Map(task, entity);

            await taskRepository.Update(updated);

            return(await taskRepository.SaveChanges());
        }
Exemple #3
0
        public async Task <IActionResult> Edit([FromForm] EditTaskDto taskDto)
        {
            if (!ModelState.IsValid)
            {
                return(View("Edit", taskDto.Id));
            }
            var results = await _taskService.PutAsync(taskDto);

            if (results.StatusCode == HttpStatusCode.OK)
            {
                return(RedirectToAction("Index"));
            }
            ViewBag.Errors = new List <string>();
            ViewBag.Errors = results.Exception;
            return(View());
        }
Exemple #4
0
        public IActionResult UpdateTask(Guid taskId, [FromBody] EditTaskDto taskDto)
        {
            if (taskDto == null || taskId != taskDto.Id)
            {
                return(BadRequest(ModelState));
            }

            var taskExists = _db.Tasks.Any(x => x.Id == taskId);

            if (!taskExists)
            {
                return(NotFound("تسک یافت نشد."));
            }

            var taskNameExists = _db.Tasks.Any(x => x.Id != taskDto.Id && x.Name == taskDto.Name);

            if (taskNameExists)
            {
                ModelState.AddModelError("", "نام تسک تکراری می باشد.");
                return(StatusCode(409, ModelState));
            }

            if (taskDto.ProjectId != null)
            {
                var projectExists = _db.Projects.Any(x => x.Id == taskDto.ProjectId);
                if (!projectExists)
                {
                    return(NotFound("پروژه یافت نشد."));
                }
            }

            var task = _mapper.Map <Task>(taskDto);

            try
            {
                _db.Tasks.Update(task);
                _db.SaveChanges();
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
                return(StatusCode(500, ModelState));
            }

            return(NoContent());
        }
        public async Task <IActionResult> EditTask(EditTaskDto task)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(CustomResponse(ModelState));
                }

                var result = await taskService.EditTask(task);

                return(Ok(result));
            }
            catch (Exception e)
            {
                return(HandleException(e.Message));
            }
        }
        public async Task EditTask_GivenAnExistentTaskToEdit_ShouldEditTask()
        {
            var taskId   = Guid.NewGuid();
            var personId = Guid.NewGuid();

            var taskEntity = new Core.Entities.Task
            {
                TaskId      = taskId,
                StatusId    = 1,
                PriorityId  = 1,
                Title       = "Test Task",
                Description = "Task Test",
                AttendantId = personId,
                AuthorId    = personId,
                CreatedDate = DateTime.Now
            };
            var editedTask = new EditTaskDto
            {
                TaskId      = taskId,
                AttendantId = personId,
                AuthorId    = personId,
                StatusId    = 1,
                PriorityId  = 1,
                Title       = "Test Task edit",
                Description = "Task Test edit"
            };

            taskRepositoryMock.Setup(s => s.GetSingleByCondition(It.IsAny <Expression <Func <Core.Entities.Task, bool> > >()))
            .Returns(Task.FromResult(taskEntity));

            taskRepositoryMock.Setup(s => s.Update(It.IsAny <Core.Entities.Task>()))
            .Returns(Task.CompletedTask);

            taskRepositoryMock.Setup(s => s.SaveChanges())
            .Returns(Task.FromResult(true));

            var taskService = new TaskService(taskRepositoryMock.Object, mapper, converter);
            var response    = await taskService.EditTask(editedTask);

            taskRepositoryMock.Verify(v => v.SaveChanges(), Times.AtLeastOnce);

            Assert.IsTrue(response);
        }
        public async Task EditTask_GivenUnexistentTaskToEdit_ShouldReturnNull()
        {
            var task = new EditTaskDto
            {
                AttendantId = Guid.NewGuid(),
                AuthorId    = Guid.NewGuid(),
                StatusId    = 1,
                PriorityId  = 1,
                Title       = "Test Task",
                Description = "Task Test"
            };

            taskRepositoryMock.Setup(s => s.GetSingleByCondition(It.IsAny <Expression <Func <Core.Entities.Task, bool> > >()))
            .Returns(Task.FromResult <Core.Entities.Task>(null));

            var taskService = new TaskService(taskRepositoryMock.Object, mapper, converter);
            var response    = await taskService.EditTask(task);

            Assert.IsFalse(response);
        }
Exemple #8
0
        public async Task <Result> PutAsync(EditTaskDto taskDto)
        {
            var task = _mapper.Map <EditTaskDto, Core.Domain.Task>(taskDto);

            return(await _taskRepository.Put(task));
        }
Exemple #9
0
        public async Task <JsonResult> UpdateTask([FromBody] EditTaskDto taskDto)
        {
            var results = await _taskService.PutAsync(taskDto);

            return(new JsonResult(results));
        }
Exemple #10
0
 public IActionResult Edit(EditTaskDto editTaskDto)
 {
     sprintTaskRepository.EditTask(editTaskDto);
     return(Redirect("AllTaskes"));
 }
Exemple #11
0
 public IActionResult EditTask(EditTaskDto editTaskDto)
 {
     teamLeaderRepository.EditTask(editTaskDto);
     return(Redirect("ShowProject")); //redicret
 }