Пример #1
0
        public async Task <StateDTO> CreateStateAsync(ObjectId projectId, StateDTO requestedState)
        {
            var project = await _projectRepository.GetAsync(projectId);

            if (project is null)
            {
                throw new HttpStatusException(404, "Project not found");
            }

            await AuthorizeEmployeeAndLeaderRolesAsync(project);

            var state = new State()
            {
                Id            = ObjectId.GenerateNewId(),
                Phase         = requestedState.Phase,
                Name          = requestedState.Name,
                UserGenerated = true,
            };

            await _projectRepository.AddState(projectId, state);

            return(new StateDTO(state));
        }