Пример #1
0
 public ActionResult Create()
 {
     var vm = new CreateRosterViewModel
         {
             Season = DocumentSession.LatestSeasonOrDefault(DateTime.Now.Year)
         };
     return View(vm);
 }
Пример #2
0
        public ActionResult Create(CreateRosterViewModel vm)
        {
            if (!ModelState.IsValid) return View(vm);

            var roster = new Roster(
                vm.Season,
                vm.Turn,
                vm.BitsMatchId,
                vm.Team,
                vm.TeamLevel,
                vm.Location,
                vm.Opponent,
                vm.Date,
                vm.IsFourPlayer);
            DocumentSession.Store(roster);
            return RedirectToAction("Index");
        }
Пример #3
0
        public ActionResult Edit(string id, CreateRosterViewModel vm)
        {
            if (!ModelState.IsValid)
                return View(vm);

            var roster = DocumentSession.Load<Roster>(id);
            if (roster == null) throw new HttpException(404, "Roster not found");

            roster.Location = vm.Location;
            roster.Opponent = vm.Opponent;
            roster.Season = vm.Season;
            roster.Team = vm.Team;
            roster.TeamLevel = vm.TeamLevel;
            roster.Turn = vm.Turn;
            roster.BitsMatchId = vm.BitsMatchId;
            roster.IsFourPlayer = vm.IsFourPlayer;
            roster.Date = vm.Date;

            return RedirectToAction("Index");
        }