Пример #1
0
        public async Task <IActionResult> Update([FromForm] ProjectUpdateRequestModel projectUpdateRequestModel)
        {
            var userId = this.User.GetId();

            var isProjectUpdateSuccessful = await this.projectService.UpdateProject(projectUpdateRequestModel, userId);

            var isProjectTechnologiesUpdateSuccessful = await this.projectTecnologyService.UpdateProjectTechnologies(projectUpdateRequestModel.Id, projectUpdateRequestModel.Technologies);

            if (!isProjectUpdateSuccessful || !isProjectTechnologiesUpdateSuccessful)
            {
                return(BadRequest());
            }

            return(Ok());
        }
Пример #2
0
        public async Task <bool> UpdateProject(ProjectUpdateRequestModel projectUpdateRequestModel, string userId)
        {
            var project = await this.GetProjectByIdAndUserId(projectUpdateRequestModel.Id, userId);

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

            project.Title       = projectUpdateRequestModel.Title;
            project.Description = projectUpdateRequestModel.Description;

            await this.personalBlogDbContext.SaveChangesAsync();

            return(true);
        }