Beispiel #1
0
 public static VoteItem Map(Vote vote, string userName)
 {
     var result = new VoteItem
         {
             Date = DateTime.Now.ToString("yyyy-MM-dd"),
             User = userName,
             Prio1 = vote.Prio1,
             Prio2 = vote.Prio2,
             Prio3 = vote.Prio3
         };
     return result;
 }
Beispiel #2
0
        public static SaveVoteResponse SaveVote(VoteItem voteResult)
        {
            var result = new SaveVoteResponse {Status = ResponseStatus.Unknown};

            var oldVotes = LoadResults();
            var newVotes = oldVotes.Where(t => t.Date != voteResult.Date || t.User != voteResult.User).ToList();
            //var newVotes = oldVotes;
            result.Status = (oldVotes.Count > newVotes.Count) ? ResponseStatus.Update : ResponseStatus.Inserted;

            newVotes.Add(voteResult);
            SaveResults(newVotes);

            return result;
        }