Example #1
0
 public Boolean deleteTwitter(int uid, int tid)
 {
     using (var dbContext = new LOJEntities3())
     {
         Twitter twi     = new Twitter();
         var     twitter = from e in dbContext.Twitters where e.uid == uid && e.tid == tid select e;
         foreach (var t in twitter)
         {
             twi = t;
             break;
         }
         dbContext.Entry(twi).State = System.Data.Entity.EntityState.Deleted;
         try
         {
             if (dbContext.SaveChanges() > 0)
             {
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
         catch (Exception e)
         {
             return(false);
         }
     }
 }
Example #2
0
 public Dictionary <string, object> GetUpdateSendList(int ChatSessionId, String msg, int uid)
 {
     using (var dbContext = new LOJEntities3())
     {
         ChatSession chat    = new ChatSession();
         var         session = from e in dbContext.ChatSessions where e.sessionid == ChatSessionId select e;
         foreach (var u in session)
         {
             chat = u;
             break;
         }
         //List<Dictionary<String, Object>> list = new List<Dictionary<string, object>>();
         JArray array = new JArray();
         if (chat.content != "[]")
         {
             array = JArray.Parse(chat.content);
             // list = JsonConvert.DeserializeObject<List<Dictionary<String, Object>>>(chat.content);
         }
         Dictionary <string, object> dict = new Dictionary <string, object>();
         dict.Add("message", msg);
         dict.Add("uid", uid);
         dict.Add("name", UserInfoController.getUser(uid).name);
         dict.Add("avator", UserInfoController.getUser(uid).avator);
         dict.Add("date", DateTime.Now.ToString());
         String jsonStr = JsonConvert.SerializeObject(dict);
         array.Add((JObject)JsonConvert.DeserializeObject(jsonStr));
         chat.content = array.ToString();
         dbContext.Entry(chat).State = System.Data.Entity.EntityState.Modified;
         try
         {
             if (dbContext.SaveChanges() > 0)
             {
                 return(dict);
             }
             else
             {
                 return(null);
             }
         }
         catch (Exception e)
         {
             return(null);
         }
     }
 }