public void AddVote(EomVoteRequest request, string UserId) { var currentDate = _repository.GetEntities <EOM>().Max(p => p.Date); var currentEom = _repository.GetEntities <EOM>().FirstOrDefault(p => p.Date == currentDate); var hasVoted = _repository.GetEntities <EOMUserVote>().Any(v => v.UserId == UserId && v.EOMid == currentEom.Id); if (hasVoted) { return; } var vote = new EOMVote() { NominatedUserId = request.UserId, Reason = request.Reason, EOMid = currentEom.Id }; var userVote = new EOMUserVote() { UserId = UserId, EOMid = currentEom.Id }; _repository.Add(userVote); _repository.Add(vote); _repository.SaveChanges(); }
public void AddVote(EomVoteRequest request) { var userId = UserId; _eomService.AddVote(request, userId); }
public void AddVote(EomVoteRequest request, string UserId) { var currentDate = _repository.GetEntities<EOM>().Max(p => p.Date); var currentEom = _repository.GetEntities<EOM>().FirstOrDefault(p => p.Date == currentDate); var hasVoted = _repository.GetEntities<EOMUserVote>().Any(v => v.UserId == UserId && v.EOMid == currentEom.Id); if (hasVoted) return; var vote = new EOMVote() { NominatedUserId = request.UserId, Reason = request.Reason, EOMid = currentEom.Id }; var userVote = new EOMUserVote() { UserId = UserId, EOMid = currentEom.Id }; _repository.Add(userVote); _repository.Add(vote); _repository.SaveChanges(); }