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)); }
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")); }
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")); }