private bool IsPlanSufficient(MealPlan mealPlan, MealPlannerConfiguration config) { for (var i = 0; i < config.DaysToPlan; ++i) { var dateNeeded = DateTime.Now.Date.AddDays(i); if (!mealPlan.MealPlanDays.Any(d => d.Day.Date == dateNeeded)) { return(false); } } return(true); }
private bool IsShoppingSufficient(MealPlan mealPlan, MealPlannerConfiguration config) { for (var i = 0; i < config.ShoppingDaysNeeded; ++i) { var dateToCheck = DateTime.Now.Date.AddDays(i); var datePlan = mealPlan.MealPlanDays.FirstOrDefault(d => d.Day.Date == dateToCheck); if (datePlan != null && !datePlan.ShoppedFor) { return(false); } } return(true); }
public void SetConfiguration(MealPlannerConfiguration configuration) { var serviceConfig = new Serializer().GetConfiguration().EngineService; var serviceAddress = String.Format("http://{0}:{1}", serviceConfig.HostName, serviceConfig.Port); try { using (WebChannelFactory <IMealPlannerEngineService> cf = new WebChannelFactory <IMealPlannerEngineService>(serviceAddress)) { IMealPlannerEngineService channel = cf.CreateChannel(); channel.SetConfiguration(configuration); } } catch (Exception e) { _eventLog.WriteEntry(String.Format("Exception in SetConfiguration sending to {1}\n{2}", serviceAddress, e.Message), EventLogEntryType.Error, 0); new Serializer().SetConfiguration(configuration); } }
public void SetConfiguration(MealPlannerConfiguration configuration) { new Serializer().SetConfiguration(configuration); }
private DefaultEngineViewPersistModel MealPlannerConfigurationToDefaultEngineViewMOdel(MealPlannerConfiguration configuration) { return(new DefaultEngineViewPersistModel { HostName = configuration.EngineService.HostName, Port = configuration.EngineService.Port }); }
private MealPlannerConfigurationViewPersistModel MealPlannerConfigurationToViewModel(MealPlannerConfiguration configuration) { return(new MealPlannerConfigurationViewPersistModel { EngineServiceHostName = configuration.EngineService.HostName, EngineServicePort = configuration.EngineService.Port, WebServiceHostName = configuration.WebService.HostName, WebServicePort = configuration.WebService.Port, NotifyIconServiceHostName = configuration.NotifyIconService.HostName, NotifyIconServicePort = configuration.NotifyIconService.Port, DaysToPlan = configuration.DaysToPlan, ShoppingDaysNeeded = configuration.ShoppingDaysNeeded }); }