예제 #1
0
        public async Task <ProjectViewModel> UpdateProject(UpdateProjectPayload payload, Guid projectId, Guid userId)
        {
            var project = this.repository.ObjectQuery.FirstOrDefault(x => x.Id == projectId);

            if (project is null)
            {
                throw new ArgumentException("Unable to find the master project");
            }
            project.Name        = payload.Name;
            project.Description = payload.Description;
            project.SwaggerUrl  = payload.SwaggerUrl;
            this.repository.Update(project);
            return(this.Map <ProjectViewModel, ProjectListItem>(this.repository.QueryAsync().FirstOrDefault(x => x.Id == project.Id)));
        }
예제 #2
0
        public async Task <ActionResult <ProjectViewModel> > Put(Guid id, [FromBody] UpdateProjectPayload value)
        {
            try
            {
                var result = await service.UpdateProject(value, id, this.UserId);

                return(Ok(result));
            }
            catch (ArgumentException ex)
            {
                return(NotFound(ex.Message));
            }
            catch (ProjectException ex)
            {
                return(NotFound(ex.Message));
            }
        }