예제 #1
0
        public ActionResult EditTournament(int tournamentId)
        {
            var dbModel = _tournamentManager.Tournaments
                .Where(x => x.Id == tournamentId)
                .FirstOrDefault();

            var viewModel = new EditTournamentViewModel
            {
                Id = dbModel.Id,
                Title = dbModel.Title,
                Description = dbModel.Description,
                StartDate = dbModel.StartDate.Date,
                EndDate = dbModel.EndDate.Date,
                StartTime = dbModel.StartDate.TimeOfDay,
                EndTime = dbModel.EndDate.TimeOfDay,
                MaxUsers = dbModel.MaxUsers,
                IsActive = dbModel.IsActive,
                IsConfigured = dbModel.IsConfigured
            };

            return View(viewModel);
        }
예제 #2
0
        public ActionResult EditTournament(EditTournamentViewModel viewModel)
        {
            var tour = new SAP.DAL.Tables.Tournament
            {
                Id = viewModel.Id,
                Title = viewModel.Title,
                Description = viewModel.Description,
                StartDate = viewModel.StartDate.Add(viewModel.StartTime),
                EndDate = viewModel.EndDate.Add(viewModel.EndTime),
                MaxUsers = viewModel.MaxUsers
            };

            bool result = _tournamentManager.EditTournament(tour);

            if (result)
                TempData["Alert"] = SetAlert.Set("Poprawnie zmodfyfikowano turniej " + viewModel.Title, "Sukces", AlertType.Success);
            else
                TempData["Alert"] = SetAlert.Set("Wystąpił błąd, prosimy spróbować później", "Błąd", AlertType.Danger);

            return RedirectToAction("Index");
        }