public ActionResult Create()
        {
            logger.Debug("User " + WebSecurity.GetUserId(User.Identity.Name) +
                         " \"" + User.Identity.Name + "\" visited TournamentsManagement/Tournament/Create");

            var model = new viewModels.NewTournamentViewModel();

            return(View(model));
        }
        public ActionResult Create(viewModels.NewTournamentViewModel Model)
        {
            if (ModelState.IsValid)
            {
                int tournamentID = -1;

                // Attempt to create new tournament
                try
                {
                    Tournament tournament = new Tournament
                    {
                        Name   = Model.Name,
                        Type   = (TournamentTypes)Model.TournamentTypesListID,
                        Format = (TournamentFormats)Model.TournamentFormatsListID,

                        ShowSolutionSendingTime = Model.ShowSolutionSendingTime,
                        ShowTimer = Model.ShowTimer,

                        StartDate = Model.StartDate.Add(Model.StartTime.TimeOfDay),
                        EndDate   = Model.EndDate.Add(Model.EndTime.TimeOfDay)
                    };
                    int userID = WebSecurity.CurrentUserId;
                    if (userID != 1)
                    {
                        UserProfile user = repository.Users.FirstOrDefault(u => u.UserId == userID);
                        tournament.UsersCanModify = new List <UserProfile>();
                        tournament.UsersCanModify.Add(user);
                    }
                    tournamentID = repository.AddTournament(tournament);

                    if (tournament.Type == TournamentTypes.Close)
                    {
                        repository.BindUserToTournament(tournament.TournamentID, WebSecurity.GetUserId(User.Identity.Name));
                    }

                    logger.Info("User " + WebSecurity.GetUserId(User.Identity.Name) +
                                " \"" + User.Identity.Name + "\" create tournament " + tournamentID + " \"" + Model.Name + "\"");

                    return(RedirectToAction("BindProblemsToTournament", new { tournamentID = tournament.TournamentID }));
                }
                catch (Exception ex)
                {
                    logger.Error("Error occurred on user " + WebSecurity.GetUserId(User.Identity.Name) +
                                 " \"" + User.Identity.Name + "\" creating tournament " + tournamentID + " \"" + Model.Name + "\": ", ex);

                    ModelState.AddModelError("", "Произошла ошибка при создании турнира");
                }
            }

            return(View(Model));
        }
        public ActionResult Create()
        {
            logger.Debug("User " + WebSecurity.GetUserId(User.Identity.Name) +
                " \"" + User.Identity.Name + "\" visited TournamentsManagement/Tournament/Create");

            var model = new viewModels.NewTournamentViewModel();
            return View(model);
        }