public ActionResult WeekPlanner(int?id = null) { Planner currentPlanner; List <Goal> inboxGoals; if (id != null) { currentPlanner = _context.Planners.Find(id); inboxGoals = null; } else { currentPlanner = GetCurrentPlanner(PlannerPeriod.WEEK); inboxGoals = _context.Goals .Where(i => i.StatusId == (int)GoalStatus.NEW).ToList(); } var viewModel = new PlannerViewModel { Planner = currentPlanner, InboxGoals = inboxGoals }; return(View(viewModel)); }
public ActionResult MakePlanner([Bind(Include = "ID,RecipeID,OnDate,Weight")] PlannerViewModel plannerViewModel) { var customerId = GetCustomerId(); var customerApps = context.Planner.Where(a => a.CustomerID == customerId).ToList(); foreach (var app in customerApps) { if (app.OnDate == plannerViewModel.OnDate && app.RecipeID == plannerViewModel.RecipeID) { return(RedirectToAction("CannotAddtoPlanner")); } } var planner = new Planner() { CustomerID = customerId, RecipeID = plannerViewModel.RecipeID, OnDate = plannerViewModel.OnDate, Weight = plannerViewModel.Weight, Calconsumed = plannerViewModel.Weight * context.Recipes.FirstOrDefault(a => a.ID == plannerViewModel.RecipeID).Calper100gram, }; context.Planner.Add(planner); context.SaveChanges(); return(RedirectToAction("ViewRecipes")); }
public ActionResult MakePlanner(string id) { int a = Convert.ToInt32(id); var recipe = context.Recipes.FirstOrDefault(d => d.ID == a); var planner = new PlannerViewModel(); planner.RecipeID = recipe.ID; planner.RecipeName = recipe.RecipeName; return(View(planner)); }
protected override async void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) { _loading = true; _vm = (PlannerViewModel)DataContext; _vm.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(_vm_PropertyChanged); bool keepValues = (e.NavigationMode == System.Windows.Navigation.NavigationMode.Back); string from = null; string to = null; string via = null; DateTime?dateTime = null; if (this.NavigationContext.QueryString.ContainsKey("from")) { from = this.NavigationContext.QueryString["from"]; } if (this.NavigationContext.QueryString.ContainsKey("to")) { to = this.NavigationContext.QueryString["to"]; } if (this.NavigationContext.QueryString.ContainsKey("via")) { via = this.NavigationContext.QueryString["via"]; } if (this.NavigationContext.QueryString.ContainsKey("dateTime")) { string d = this.NavigationContext.QueryString["dateTime"]; DateTime tryDate; if (DateTime.TryParse(d, CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal, out tryDate)) { dateTime = DateTime.Parse(d, CultureInfo.InvariantCulture); } } _vm.InitValues(from, to, via, keepValues, dateTime); _loading = false; SetPin(); try { ViewModelLocator.MainStatic.Update(); } catch { } base.OnNavigatedTo(e); }
public PlannerController(PlannerViewModel ViewModel, MainMenuViewModel MenuViewModel, IMessenger Messenger, IMapper Mapper, ISettingsRepository SettingsRepository) { if (Application.Current != null) { Application.Current.DispatcherUnhandledException += onCurrentDispatcherUnhandledException; } AppDomain.CurrentDomain.UnhandledException += onDomainUnhandledException; Dispatcher.CurrentDispatcher.UnhandledException += onCurrentDispatcherUnhandledException; TaskScheduler.UnobservedTaskException += onUnobservedTaskException; System.Windows.Forms.Application.ThreadException += onThreadException; viewModel = ViewModel; menuViewModel = MenuViewModel; messenger = Messenger; mapper = Mapper; settingsRepository = SettingsRepository; }
public PlannerPage() { InitializeComponent(); BindingContext = viewModel = new PlannerViewModel(); }