public PraiseLog GetPraiseLog(int userid, int rid, PraiseType type = PraiseType.Question)
 {
     try
     {
         return(_db.Praises.FirstOrDefault(n => n.UserId == userid && rid == n.RelateId && n.PraiseType == type));
     }
     catch (Exception e)
     {
         Logger.Debug("GetPraiseLog Error" + e.Message);
         return(null);
     }
 }
        private PortalResult CreatePraise(int userid, int rid, int num, PraiseType type = PraiseType.Question)
        {
            var p = new PraiseLog()
            {
                UserId = userid, RelateId = rid, PraiseType = type
            };

            _praiseRepository.Insert(p);
            return(new PortalResult(true)
            {
                Num = num
            });
        }
 private PortalResult CreatePraise(int userid, int rid, int num, PraiseType type = PraiseType.Question)
 {
     using (var db = new PortalDb())
     {
         var p = new PraiseLog()
         {
             UserId = userid, RelateId = rid, PraiseType = type
         };
         db.Praises.Add(p);
         db.SaveChanges();
         return(new PortalResult(true)
         {
             Num = num
         });
     }
 }
 public PraiseLog GetPraiseLog(int userid, int rid, PraiseType type = PraiseType.Question)
 {
     return(_praiseRepository.Table.FirstOrDefault(n => n.UserId == userid && rid == n.RelateId && n.PraiseType == type));
 }