예제 #1
0
        public HttpResponseMessage SetConfig(ConfigModel configModel)
        {
            if (!ModelState.IsValid || configModel == null)
                return Request.CreateResponse(HttpStatusCode.BadRequest);

            var scheduledTasks = new List<ScheduledTaskDto>();

            var config = AdminManager.GetConfig().UpdateConfigFromModel(configModel);

            // update scheduled tasks or create new
            foreach (var scheduledTaskModel in configModel.ScheduledTasks)
            {
                var scheduledTask = AdminManager.GetScheduledTask(scheduledTaskModel);
                if (scheduledTask == null)
                {
                    scheduledTask = new ScheduledTaskDto(scheduledTaskModel);
                }
                else
                {
                    scheduledTask.UpdateScheduledTaskFromModel(scheduledTaskModel);
                }

                scheduledTasks.Add(scheduledTask);
            }

            AdminManager.Save(config, scheduledTasks);
            return new HttpResponseMessage(HttpStatusCode.Accepted);
        }
예제 #2
0
        public ConfigDto UpdateConfigFromModel(ConfigModel model)
        {
            YoutubeApiKey = model.YoutubeApiKey;

            return this;
        }