public static int SaveChat(ChatInfo ctx) { // var edm = new BaoXinEntities(); // ChatInfo info = new ChatInfo(); // info.user_from = ctx.user_from; // info.user_to = ctx.user_to; // info.sendtime = ctx.sendtime; // info.ispublic = true; // info.content = ctx.content; // info.IsOpen = false; // //DbEntityEntry<ChatInfo> entry = edm.Entry<ChatInfo>(info); // //entry.State = System.Data.EntityState.Added; //// edm.ChatInfo.Add(info); // edm.Entry(info).State = EntityState.Added; // return edm.SaveChanges(); if (!string.IsNullOrEmpty(ctx.content)) { ctx.content = ctx.content.Replace("'", "‘").Replace("'", "‘"); } var sql = "Insert Into ChatInfo(user_from,user_to,sendtime,ispublic,content,IsOpen)values('"+ctx.user_from+"','"+ctx.user_to+"',getdate(),1,'"+ctx.content+"',0)"; return SqlServerHelper.ExecuteNonQuery(CommandType.Text, sql, null); }
public JsonResult SendChat(string tid,string ctx) { ChatInfo cinfo = new ChatInfo(); if (CurrentUser != null) { cinfo.user_from = CurrentUser.Id.ToString(); cinfo.user_to = tid; cinfo.sendtime = DateTime.Now; cinfo.content = ctx; cinfo.ispublic = true; ChatBLL cbll = new ChatBLL(); cbll.SaveChat(cinfo); } return this.Json("success", JsonRequestBehavior.AllowGet); }
public int SaveChat(ChatInfo ct) { return ChatInfoDAL.SaveChat(ct); }