コード例 #1
0
ファイル: VotesController.cs プロジェクト: IvanDimPetrov/DAIS
        public async Task <IActionResult> Create()
        {
            var model = new CreateVoteViewModel()
            {
                EmployeeList = new SelectList(await this.GetEmployeeWithoutVote(), "UserName", "Name"),
                Owner        = this.User.Identity.Name,
            };

            return(View(model));
        }
コード例 #2
0
        public IActionResult Create(CreateVoteViewModel vote)
        {
            if (ModelState.IsValid)
            {
                Vote model = new Vote();
                model.Name     = vote.Name;
                model.OptionId = vote.OptionId;
                _voteRep.Create(model);
                return(RedirectToAction(nameof(Index)));
            }

            return(View("Index.cshtml"));
        }
コード例 #3
0
ファイル: VotesController.cs プロジェクト: IvanDimPetrov/DAIS
        public async Task <IActionResult> Create(CreateVoteViewModel model)
        {
            if (!this.ModelState.IsValid)
            {
                model.EmployeeList = new SelectList(await this.GetEmployeeWithoutVote(), "UserName", "Name");
                return(View(model));
            }

            var voteToInsert = new Vote()
            {
                Owner    = model.Owner,
                Receiver = model.Reciever,
                IsActive = true
            };

            await this._votesRepository.InsertVote(voteToInsert);

            return(RedirectToAction("ActiveVotes", "Votes"));
        }