private static EventAndTime RetrieveArgsFromConsole(IEnumerable <Event> events) { var dictionaryEvents = new Dictionary <int, Event>(); var index = 0; Console.WriteLine("What event you want update the interval execution?"); foreach (var evnt in events) { Console.WriteLine(String.Format("{0}. {1}", index, evnt.Name)); dictionaryEvents.Add(index, evnt); index++; } var getEventIndex = Console.ReadLine(); Console.WriteLine("How much minutes you want for these events?"); var time = Console.ReadLine(); var eventId = GetEventId(dictionaryEvents, int.Parse(getEventIndex)); var EventAndMinutesObject = new EventAndTime { EventId = eventId, Time = int.Parse(time) }; return(EventAndMinutesObject); }
static void Main(string[] args) { var configuration = GetConfiguration(); RegisterServices(configuration); var eventService = _serviceProvider.GetService <IEventService>(); var events = eventService.GetAll(); var eventAndMinutes = new EventAndTime(); if (args == null || args.Length == 0) { eventAndMinutes = RetrieveArgsFromConsole(events); } var ruleRepository = _serviceProvider.GetService <IRuleRepository>(); var getRulesForEvent = ruleRepository.GetAllRulesWithEventId(eventAndMinutes.EventId); var triggerFieldService = _serviceProvider.GetService <ITriggerFieldService>(); foreach (var rule in getRulesForEvent) { var containsIntervalFieldDB = rule.TriggerFields.Where(x => x.Key == "ExecutionIntervalInMinutes"); if (containsIntervalFieldDB == null) { //var a = "creem la vulve"; triggerFieldService.AddTriggerField(rule, eventAndMinutes.Time); } else { var b = "s'actualitza le mamelons"; } } DisposeServices(); }