public PlanDetailsPage(PlanIProgram plan) { InitializeComponent(); BindingContext = _model = new PlanDetailsViewModel() { PlanIProgram = plan }; }
public async Task <IActionResult> Details(int id) { var viewModel = new PlanDetailsViewModel() { Plan = await _planService.GetWithDetailsAsync(id), DayNames = await _dayNameService.GetAllAsync() }; return(View(viewModel)); }
public async Task <IActionResult> Index([FromServices] PlanDetailsViewModel toView) { //akutalnie zalogowany użytkownik var user = await _userManager.GetUserAsync(User); // pobieramy jego ostatni dodany plan var plan = _planService.LastAddedPlan(user.UserName); if (plan != null) { var days = _dayNameService.GetAll(); toView.PlanName = plan.Name; var dayNamesList = new List <DayNameViewModel>(); foreach (var day in days) { var recipesInDay = plan.RecipePlans.Where(a => a.DayName.Id == day.Id); if (recipesInDay.Count() >= 1) { var tempDay = new DayNameViewModel { DayName = day.Name }; var recipesList = new List <RecipeView>(); foreach (var recipe in recipesInDay) { var tempRecipes = new RecipeView(); tempRecipes.Id = recipe.Recipe.Id; tempRecipes.MealName = recipe.MealName; tempRecipes.RecipeName = recipe.Recipe.Name; recipesList.Add(tempRecipes); } tempDay.RecipeList = recipesList; dayNamesList.Add(tempDay); } } toView.DayNames = dayNamesList; } else { toView = null; } //przekazujemy do widoku liczbę dodanych planów i przepisów ViewBag.AddedRecipie = _recipeService.countAddedByUser(user.UserName); ViewBag.AddedPlans = _planService.CountAddedByUser(user.UserName); ViewBag.userName = user.Name; // do _LoginPartial.cshtml return(View(toView)); }
// GET: DietPlanController/DayList/5 public ActionResult DayList(int id) { var model = new PlanDetailsViewModel { DailyDietPlans = _dietPlanService.ListDailyDietPlans(id) }; var dietPlan = _dietPlanService.GetDietPlan(id); if (dietPlan != null) { model.DietPlanNo = dietPlan.PlanNo; model.DietPlanId = dietPlan.Id; model.PlanCaloriesPerDay = dietPlan.CaloriesPerDay; } return(View(model)); }
public IActionResult Details(int id) { PlanDetailsViewModel planDetailsViewModel = new PlanDetailsViewModel() { Plan = planService.PlanDetails(id) }; planDetailsViewModel.DayNames = new List <DayName>(); planDetailsViewModel.RecipePlans = recipePlanService.GetAllByPlanIdDisplayOrderAscending(planDetailsViewModel.Plan.Id); foreach (var recipePlan in planDetailsViewModel.RecipePlans) { if (!planDetailsViewModel.DayNames.Contains(recipePlan.DayName)) { planDetailsViewModel.DayNames.Add(recipePlan.DayName); } } return(View(planDetailsViewModel)); }
public PlanDetailsView(Plan plan) { InitializeComponent(); BindingContext = new PlanDetailsViewModel(plan, Navigation); }