示例#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>
        /// Strips the miscellaneous config entry for a project of additional informations
        /// </summary>
        /// <param name="configEntry">Config Entry to strip</param>
        /// <returns>Trimmed miscellaneous config entry</returns>
        private TrimmedMiscConfig StripMiscConfig(MiscProjectConfig configEntry)
        {
            TrimmedMiscConfig trimmedConfig = new TrimmedMiscConfig();

            trimmedConfig.HoursPerDay    = configEntry.HoursPerDay;
            trimmedConfig.MinutesPerHour = configEntry.MinutesPerHour;

            return(trimmedConfig);
        }