Пример #1
0
        public async Task <IActionResult> Post([FromBody] CreateProjectModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var project = new Project {
                        Name = model.ProjectName
                    };

                    var projectId = await _tenantRepository.AddProjectToTeam(project, TenantId); //you need to find team Id!!!!!!!!!!!!!!!!!!!!!!!!!!

                    var user = await _userService.GetCurrentUserAsync(TenantId);

                    await _tenantRepository.AddProjectUser(user.Id, projectId, TenantId, Role.SuperAdministrator);

                    return(Ok(new { id = projectId, project_name = model.ProjectName, users = new List <User> {
                                        user
                                    } }));
                }
                catch (Exception ex)
                {
                    return(BadRequest(new { ex.Message }));
                }
            }

            return(BadRequest(ModelState));
        }