public async Task <IActionResult> AddToSubProject(AddCostAddToSubProjectInputModel inputModel)
        {
            if (inputModel.SubProjectId == null)
            {
                this.ModelState.AddModelError(string.Empty, "Project part doesn`t exist!");
            }

            var selectedProject = await this.projectsService
                                  .GetByIdAsync <AddCostAddToSubProjectProjectViewModel>(inputModel.ProjectId);

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

            if (!this.ModelState.IsValid)
            {
                var projects = await this.GetProjects(this.User);

                this.ViewData["Projects"] = projects;
                this.ViewData["Project"]  = selectedProject;

                return(this.View(inputModel));
            }

            await this.additionalCostsService.AddAsync <AddCostAddToSubProjectInputModel>(inputModel);

            return(this.RedirectToAction(nameof(this.CostsBySubProject), new { subProjectId = inputModel.SubProjectId }));
        }
        public async Task AddAsyncShouldAddCostCorrectly()
        {
            // Arrange
            var inputModel = new AddCostAddToSubProjectInputModel
            {
                Name = "Print",
                Description = "Drawings",
                PricePerQuantity = 5.50M,
                Quantity = 20,
                ProjectId = 1,
                SubProjectId = 1,
            };

            // Act
            var expected = new AdditionalCost
            {
                Name = "Print",
                Description = "Drawings",
                PricePerQuantity = 5.50M,
                Quantity = 20,
                TotalCost = 5.5M * 20,
                ProjectId = 1,
                SubProjectId = 1,
            };

            var actual = await this.AdditionalCostsService
                .AddAsync<AddCostAddToSubProjectInputModel>(inputModel);

            // Assert
            Assert.Equal(expected.Name, actual.Name);
            Assert.Equal(expected.Description, actual.Description);
            Assert.Equal(expected.PricePerQuantity, actual.PricePerQuantity);
            Assert.Equal(expected.Quantity, actual.Quantity);
            Assert.Equal(expected.TotalCost, actual.TotalCost);
            Assert.Equal(expected.ProjectId, actual.ProjectId);
            Assert.Equal(expected.SubProjectId, actual.SubProjectId);
        }