public async Task EditAsyncShouldEditProblemCorrecty()
        {
            // Arrange
            var problem = new Problem
            {
                Id               = 1,
                Name             = "Work2",
                Instructions     = "GoGoNo",
                DueDate          = DateTime.UtcNow,
                HourlyRate       = 5.5M,
                ProgressStatusId = 3,
            };

            await this.PlanItDbContext.Problems.AddAsync(problem);

            await this.PlanItDbContext.SaveChangesAsync();

            var inputModel = new TaskEditInputModel
            {
                Id               = 1,
                Name             = "Work1",
                Instructions     = "GoGo",
                DueDate          = DateTime.Now.AddDays(10),
                HourlyRate       = 2.5M,
                ProgressStatusId = 2,
            };

            // Act
            var expected = new Problem
            {
                Id               = 1,
                Name             = "Work1",
                Instructions     = "GoGo",
                DueDate          = DateTime.UtcNow.AddDays(10),
                HourlyRate       = 2.5M,
                ProgressStatusId = 2,
            };

            var actual = await this.ProblemsService
                         .EditAsync <TaskEditInputModel>(inputModel);

            // Assert
            Assert.Equal(expected.Id, actual.Id);
            Assert.Equal(expected.Name, actual.Name);
            Assert.Equal(expected.Instructions, actual.Instructions);
            Assert.Equal(expected.DueDate?.ToString(DateTimeFormat), actual.DueDate?.ToString(DateTimeFormat));
            Assert.Equal(expected.HourlyRate, actual.HourlyRate);
            Assert.Equal(expected.ProgressStatusId, actual.ProgressStatusId);
        }
        public async Task <IActionResult> Edit(int id, TaskEditInputModel inputModel)
        {
            if (id != inputModel.Id)
            {
                return(this.NotFound());
            }

            var subProject = await this.subProjectsService
                             .GetByIdAsync <TaskEditSubProjectViewModel>(inputModel.SubProjectId);

            if (subProject == null)
            {
                this.ModelState.AddModelError(string.Empty, "Project part doesn`t exist!");
            }

            if (inputModel.DueDate != null)
            {
                if (inputModel.DueDate?.ToUniversalTime() > subProject.DueDate)
                {
                    this.ModelState.AddModelError(string.Empty, $"Due date has to be before project part Due date");
                }
            }

            if (!this.ModelState.IsValid)
            {
                var statuses = await this.progressStatusesService.GetAllAsync <TaskEditProgressStatusViewModel>();

                this.ViewData["Statuses"] = statuses;

                return(this.View(inputModel));
            }

            await this.problemsService.EditAsync <TaskEditInputModel>(inputModel);

            return(this.RedirectToAction(nameof(this.Index)));
        }