Exemplo n.º 1
0
 public bool AddVote(VoteContract vote)
 {
     try
     {
         using (var db = new SurveyDbContext())
         {
             if (!db.Vote.Any(a => a.IdVote == vote.IdVote))
             {
                 db.Vote.Add(new Data.Entities.Vote {
                     IdVote = vote.IdVote, IdAnswer = vote.IdAnswer
                 });
                 if (vote.SenderId == App.AppId)
                 {
                     db.MyVotes.Add(new Data.Entities.MyVotes {
                         IdAnswer = vote.IdAnswer, IdSurvey = vote.IdSurvey
                     });
                 }
                 db.SaveChanges();
                 return(true);
             }
             return(false);
         }
     }
     catch (Exception e)
     {
         Logger.Log(e);
         return(false);
     }
 }
 public static VoteModel GetModel(this VoteContract contract)
 {
     return(new VoteModel {
         IdVote = contract.IdVote, IdAnswer = contract.IdAnswer
     });
 }
Exemplo n.º 3
0
        public void Vote(VoteContract msg)
        {
            var service = new Services.SurveyService();

            service.AddVote(msg);
        }