コード例 #1
0
        public ActionResult Index(MyTeamViewModel model)
        {
            if(ModelState.IsValid)
            {
                // Team MUST be loaded first, then ALL the values copied over
                Team team = teamService.Get(model.Team.Id);
                TryUpdateModel(team, "Team"); // Should copy all values from model to team
                team.GameDay = dayOfWeekService.Get(model.DayOfWeekId.Value);
                teamService.Update(team);

                teamService.Commit();
                SuccessMessage(FormMessages.SaveSuccess);
            }

            foreach (ModelState modelState in ViewData.ModelState.Values)
            {
                foreach (ModelError error in modelState.Errors)
                {
                    Console.Out.WriteLine(error.ErrorMessage);
                }
            }

            model.DaysOfWeek = new SelectList(dayOfWeekService.Get(), "Id", "Day", model.DayOfWeekId);

            return View(model);
        }
コード例 #2
0
        public ActionResult Create()
        {
            MyTeamViewModel model = new MyTeamViewModel();

            PopulateStaticDate(model);

            return View(model);
        }
コード例 #3
0
        public ActionResult Edit(int id)
        {
            MyTeamViewModel model = new MyTeamViewModel();

            model.Team = teamService.Get(id);

            PopulateStaticDate(model);

            return View(model);
        }
コード例 #4
0
        public ActionResult Index()
        {
            User user = membershipService.GetLoggedInUser();
            MyTeamViewModel model = new MyTeamViewModel();

            model.Team = teamService.Get(user.Team.Id);
            model.DaysOfWeek = new SelectList(dayOfWeekService.Get(), "Id", "Day", model.Team.GameDay.Id);

            return View(model);
        }
コード例 #5
0
        public ActionResult Create(MyTeamViewModel model)
        {
            if (ModelState.IsValid)
            {
                if (model.DayOfWeekId.HasValue)
                    model.Team.GameDay = dayOfWeekService.Get(model.DayOfWeekId.Value);

                // TODO FIX GameeDay is NOT being saved
                teamService.Save(model.Team);
                teamService.Commit();

                SuccessMessage(FormMessages.SaveSuccess);
                return RedirectToAction("Index");
            }

            PopulateStaticDate(model);

            return View(model);
        }
コード例 #6
0
        public ActionResult Edit(MyTeamViewModel model)
        {
            if (ModelState.IsValid)
            {
                // Team MUST be loaded first, then ALL the values copied over
                Team team = teamService.Get(model.Team.Id);
                TryUpdateModel(team, "Team"); // Should copy all values from model to team
                team.GameDay = dayOfWeekService.Get(model.DayOfWeekId.Value);
                teamService.Update(team);

                teamService.Commit();
                SuccessMessage(FormMessages.SaveSuccess);
                return RedirectToAction("Index");
            }

            PopulateStaticDate(model);

            return View(model);
        }
コード例 #7
0
 private void PopulateStaticDate(MyTeamViewModel model)
 {
     model.DaysOfWeek = new SelectList(dayOfWeekService.Get(), "Id", "Day", model.Team.GameDay.Id);
 }