Пример #1
0
 /// <summary>
 /// 增加分享次数
 /// </summary>
 /// <param name="log"></param>
 public static void AddSharesLog(SharesLog log)
 {
     using (var db = new DanfossDbEntities())
     {
         var model = db.SharesLog.FirstOrDefault(o => o.OpenId == log.OpenId);
         if (model != null)
         {
             model.Shares += 1;
             db.SharesLog.Attach(model);
             db.Entry(model).State = EntityState.Modified;
         }
         else
         {
             db.SharesLog.Add(log);
         }
         db.SaveChanges();
     }
 }
Пример #2
0
 /// <summary>
 ///  增加邮件发送记录
 /// </summary>
 /// <param name="log"></param>
 public static void AddSendEmailLog(SendEmailLog log)
 {
     try
     {
         using (var db = new DanfossDbEntities())
         {
             var model = db.Customer.FirstOrDefault(o => o.OpenId == log.OpenId);
             if (model != null)
             {
                 model.Email = log.Email;
                 db.Customer.Attach(model);
                 db.Entry(model).State = EntityState.Modified;
             }
             db.SendEmailLog.Add(log);
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         Lgr.Log.Error(ex.Message, ex);
     }
 }