public UpdateContestInputModel(Contest _contest, List<User> _Users)
        {
            this.Contests = _contest;
            this.Users = _Users;

            SelectedVoters = new List<string>();
        }
        public ActionResult Create()
        {
            var contest = new Contest();
            var users = this.ContestData.Users.All().ToList();

            var participationStrategy = Enum.GetValues(typeof(ParticipationType))
                                                       .Cast<ParticipationType>();
            var deadlineStrategy = Enum.GetValues(typeof(DeadlineType))
                                                       .Cast<DeadlineType>();
            var votingnStrategy = Enum.GetValues(typeof(VotingType))
                                                       .Cast<VotingType>();

            CreateContestInputModel inputModel = new CreateContestInputModel(contest, users, participationStrategy, deadlineStrategy, votingnStrategy);

            return this.View(inputModel);
        }
        public ActionResult Create(CreateContestInputModel model)
        {
            var ownerId = this.User.Identity.GetUserId();

            var getParticipants = new List<User>();
            var getVoters = new List<User>();

            var participationStrategy = Enum.GetValues(typeof(ParticipationType))
                                                   .Cast<ParticipationType>();
            var deadlineStrategy = Enum.GetValues(typeof(DeadlineType))
                                                       .Cast<DeadlineType>();
            var votingnStrategy = Enum.GetValues(typeof(VotingType))
                                                       .Cast<VotingType>();
            var users = this.ContestData.Users.All().ToList();

            if (model != null && this.ModelState.IsValid)
            {
                var contest = new Contest()
                {
                    Title = model.Title,
                    Description = model.Description,
                    StartDate = model.StartDate,
                    EndDate = model.EndDate,
                    VotesCount = model.VotesCount,
                    WinnersCount = model.WinnersCount,
                    OwnerId = ownerId,
                    HasEnded = false,
                    ContestStatus = ContestStatus.Active,
                    ParticipationType = (ParticipationType)Enum.Parse(typeof(ParticipationType), model.SelectParticipationStrategy.FirstOrDefault()),
                    VotingType = (VotingType)Enum.Parse(typeof(VotingType), model.SelectVotingStrategy.FirstOrDefault()),
                    DeadlineType = (DeadlineType)Enum.Parse(typeof(DeadlineType), model.SelectDeadlineStrategy.FirstOrDefault())
                };

                this.ContestData.Contest.Add(contest);
                contest.Pictures.Add(new Picture { Url = "default.jpg", UploaderId = ownerId });
                this.ContestData.SaveChanges();

                contest.Participants = GetParticipants(contest.ContestId,model, getParticipants);
                contest.Voters = GetVoters(contest.ContestId,model, getVoters);
                this.ContestData.SaveChanges();

                this.AddNotification("Contest Create",NotificationType.INFO);
                return this.RedirectToAction("Index");
            }

            model.ParticipationStrategy = participationStrategy;
            model.DeadlineStrategy = deadlineStrategy;
            model.VotingStrategy = votingnStrategy;
            model.Users = users;

            return this.View(model);
        }
        public ActionResult Update(int id)
        {
            var contests = new Contest();
            if (id == null)
            {
                return this.RedirectToAction("Index");
            }
            var contest = this.ContestData.Contest.Find(id);
            var a = contest.VotingType;

            if (contest == null)
            {
                this.AddNotification("There are now such a contest",NotificationType.ERROR);
                return  this.RedirectToAction("Index");
            }

            var users = this.ContestData.Users.All().ToList();

            var model = new UpdateContestInputModel(contests, users);
            model.VoteType = a;
            return View(model);
        }