public JsonResult Send(MesajJson MesajJson) { string conStr = Session["conStr"].ToString(); //ConfigurationManager.ConnectionStrings["MySQLConnectionString"].ConnectionString; response r = new response(); Mesaj m = new Mesaj(Convert.ToInt32(Session["CURENT_USER_ID"]), conStr); PropertyInfo[] pis = m.GetType().GetProperties(); foreach (PropertyInfo pi in pis) { pi.SetValue(m, pi.GetValue(MesajJson.Mesaj)); } m.DATA = DateTime.Now; m.ID_SENDER = Convert.ToInt32(Session["CURENT_USER_ID"]); r = m.Insert(); if (r.Status && r.InsertedId != null) { foreach (Utilizator u in MesajJson.Receivers) { MesajUtilizator mu = new MesajUtilizator(Convert.ToInt32(Session["CURENT_USER_ID"]), conStr); mu.ID_MESAJ = Convert.ToInt32(r.InsertedId); mu.ID_UTILIZATOR = Convert.ToInt32(u.ID); mu.Insert(); } } return(Json(r, JsonRequestBehavior.AllowGet)); }
public JsonResult SetDataCitire(MesajJson MesajJson) { string conStr = Session["conStr"].ToString(); //ConfigurationManager.ConnectionStrings["MySQLConnectionString"].ConnectionString; response r = new response(); Mesaj m = new Mesaj(Convert.ToInt32(Session["CURENT_USER_ID"]), conStr); PropertyInfo[] pis = m.GetType().GetProperties(); foreach (PropertyInfo pi in pis) { pi.SetValue(m, pi.GetValue(MesajJson.Mesaj)); } r = m.SetMessageReadDate(Convert.ToInt32(Session["CURENT_USER_ID"]), (DateTime)MesajJson.DataCitire); return(Json(r, JsonRequestBehavior.AllowGet)); }