示例#1
0
        public async Task <IActionResult> Update([FromForm] UpdateVotingDto dto)
        {
            if (ModelState.IsValid)
            {
                await _votingService.UpdateAsync(dto);

                return(RedirectToAction("Get", new { id = dto.Id }));
            }

            return(View(dto));
        }
示例#2
0
        public async Task UpdateAsync(UpdateVotingDto dto)
        {
            var voting = await _unitOfWork.VotingRepository.GetAsync(new GetOptions
            {
                Id = dto.Id,
                IncludeVotingOptions = true
            });

            ;

            if (voting.GetVotingStatus() == VotingStatus.Upcoming)
            {
                _mapper.Map(dto, voting);

                _unitOfWork.VotingRepository.Update(voting);

                await _unitOfWork.SaveChangesAsync();
            }
        }