Пример #1
0
        public async Task <IActionResult> SaveMiscConfig([FromBody] TrimmedMiscConfig configData)
        {
            if (configData.HoursPerDay <= 0 || configData.MinutesPerHour <= 0)
            {
                return(BadRequest());
            }

            GoNorthProject project = await _projectDbAccess.GetDefaultProject();

            MiscProjectConfig configEntry = await _projectConfigDbAccess.GetMiscConfig(project.Id);

            if (configEntry != null)
            {
                await this.SetModifiedData(_userManager, configEntry);

                configEntry.HoursPerDay    = configData.HoursPerDay;
                configEntry.MinutesPerHour = configData.MinutesPerHour;

                await _projectConfigDbAccess.UpdateMiscConfig(configEntry);
            }
            else
            {
                configEntry                = new MiscProjectConfig();
                configEntry.ProjectId      = project.Id;
                configEntry.HoursPerDay    = configData.HoursPerDay;
                configEntry.MinutesPerHour = configData.MinutesPerHour;

                await this.SetModifiedData(_userManager, configEntry);

                await _projectConfigDbAccess.CreateMiscConfig(configEntry);
            }

            return(Ok(configData));
        }
Пример #2
0
        /// <summary>
        /// Gets the miscellaneous config for a project
        /// </summary>
        /// <param name="projectId">Project id</param>
        /// <returns>Config</returns>
        public async Task <MiscProjectConfig> GetMiscConfig(string projectId)
        {
            MiscProjectConfig configEntry = await _projectConfigDbAccess.GetMiscConfig(projectId);

            if (configEntry != null)
            {
                return(configEntry);
            }

            return(GetDefaultMiscConfig(projectId));
        }