Ejemplo n.º 1
0
        public IActionResult Vote(UserVoteFormData formData)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest();
            }

            _context.Vote(formData);

            return Ok();

        }
Ejemplo n.º 2
0
        public void Vote(UserVoteFormData formData)
        {
            var resolution = _context.Resolutions.FirstOrDefault(x => x.Id == formData.ResolutionId);

            if (resolution.ExpirationDate > DateTime.Now)
            {
                var newVote = _mapper.Map <ResidentResolution>(formData);
                newVote.VoteDate = DateTime.Now;
                _context.ResidentResolution.Add(newVote);
                _context.SaveChanges();
            }
        }