コード例 #1
0
        public ActionResult Update(int id,UpdateContestInputModel model)
        {
            var getVoters = new List<User>();
            if (id == null)
            {
                return this.RedirectToAction("Index");
            }
            var contest = this.ContestData.Contest.Find(id);

            if (contest == null)
            {
                return this.RedirectToAction("Index");
            }

            if (model.SelectedVoters != null)
            {
                foreach (var voterId in model.SelectedVoters)
                {
                    var user = this.ContestData.Users.All().First(u => u.Id == voterId);
                    getVoters.Add(user);
                }
            }

            contest.EndDate = model.EndDate;
            contest.Description = model.Description;
            contest.Voters = getVoters;

            this.ContestData.Contest.Update(contest);
            this.ContestData.SaveChanges();

            this.AddNotification("Successfuly update contest",NotificationType.SUCCESS);
            return this.RedirectToAction("Index");
        }
コード例 #2
0
        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);
        }