示例#1
0
        public async Task <IActionResult> UpdateProjectAsync(int projectId, [FromBody] UpdateProjectRequest request, [FromServices] IUpdateProjectCommand command, [FromServices] IGetProjectQuery query)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            string user    = User.Identity.Name;
            var    project = await query.RunAsync(projectId);

            try
            {
                var authorizationResult = await _authorizationService.AuthorizeAsync(User, project, Operations.Update);

                if (authorizationResult.Succeeded)
                {
                    ProjectResponse response = await command.ExecuteAsync(projectId, request, user);

                    return(response == null
                        ? (IActionResult)NotFound("Project Not Found")
                        : Ok(response));
                }
                return(StatusCode(403, "Вы не можете изменить этот проект!"));
            }
            catch (ProjectLockedException)
            {
                return(BadRequest("В данный момент изменение проекта невозможно!"));
            }
            catch (DbUpdateConcurrencyException)
            {
                return(BadRequest("Ошибка параллелизма!"));
            }
        }
示例#2
0
        public async Task <IActionResult> UpdateProjectAsync([FromBody] UpdateProjectRequest request, [FromServices] IUpdateProjectCommand command)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            ProjectResponse response = await command.ExecuteAsync(request);

            return(response == null ? (IActionResult)NotFound() : Ok(response));
        }
示例#3
0
        public async Task <IActionResult> UpdateProjectAsync(int projectId, [FromBody] UpdateProjectRequest request, [FromServices] IUpdateProjectCommand command)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var response = await command.ExecuteAsync(projectId, request);

            if (response == null)
            {
                return(NotFound());
            }

            return(Ok(response));
        }