示例#1
0
        public ActionResult MakeVoting()
        {
            string username = this.User.Identity.Name;
            ICollection <EmployeeDescription> employees = this.votingManager.GetAllEmployeesExceptForCurrentUser(username);
            ICollection <PresentDescription>  presents  = this.votingManager.GetAllPresents();

            MakeVotingBindingModel makeVotingModel = new MakeVotingBindingModel();

            makeVotingModel.ReceiversSelectList = new SelectList(employees, "Id", "Name", "-- none --");
            makeVotingModel.PresentsSelectList  = new SelectList(presents, "Id", "Name", "-- none --");

            return(this.View(makeVotingModel));
        }
示例#2
0
        public ActionResult MakeVoting(MakeVotingBindingModel makeVotingModel)
        {
            int userId = this.User.GetUserId();

            bool makeVotingResult = this.votingManager.MakeVoting(userId, makeVotingModel.ReceiverId, makeVotingModel.PresentId);

            if (!makeVotingResult)
            {
                this.TempData.Add(TempDataErrorMessageKey, MakeVotingError);
                return(this.RedirectToAction(nameof(VotingsController.MakeVoting)));
            }

            this.TempData.Add(TempDataSuccessMessageKey, MakeVotingSuccessful);
            return(this.RedirectToAction(nameof(VotingsController.Index)));
        }