Пример #1
0
        /// <summary>
        /// Configures the project
        /// </summary>
        /// <returns>Task</returns>
        private static async Task ConfigureProject()
        {
            ServiceProvider serviceProvider = ServiceProviderBuilder.BuildServiceProvider();

            IProjectDbAccess projectDbAccess = serviceProvider.GetService <IProjectDbAccess>();
            GoNorthProject   defaultProject  = await projectDbAccess.GetDefaultProject();

            if (defaultProject != null)
            {
                MessageService.PrintDefaultProjectExistMessage();
                return;
            }

            try
            {
                string         displayName     = MessageService.GetDefaultProjectName();
                GoNorthProject projectToCreate = new GoNorthProject
                {
                    Name      = displayName,
                    IsDefault = true
                };
                await projectDbAccess.CreateProject(projectToCreate);

                MessageService.PrintSuccessCreatingDefaultProject();
            }
            catch (Exception ex)
            {
                MessageService.PrintErrorCreatingDefaultProject(ex);
            }
        }
Пример #2
0
        public async Task <IActionResult> CreateProject([FromBody] GoNorthProject project)
        {
            if (string.IsNullOrEmpty(project.Name))
            {
                return(BadRequest());
            }

            try
            {
                project = await _projectDbAccess.CreateProject(project);

                await _timelineService.AddTimelineEntry(null, TimelineEvent.ProjectCreated, project.Name);

                return(Ok(project.Id));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "Could not create project {0}", project.Name);
                return(StatusCode((int)HttpStatusCode.InternalServerError));
            }
        }