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)); }
public JsonResult GetSentMessages(int?id, int?_START_LIMIT, int?_END_LIMIT) // id_dosar { MesajView mv = new MesajView(); string conStr = Session["conStr"].ToString(); //ConfigurationManager.ConnectionStrings["MySQLConnectionString"].ConnectionString; int uid = Convert.ToInt32(Session["CURENT_USER_ID"]); Dosar d = new Dosar(uid, conStr, Convert.ToInt32(id)); Mesaj mesaj = new Mesaj(uid, conStr); Utilizator[] us = (Utilizator[])mesaj.GetReceivers().Result; Utilizator s = (Utilizator)mesaj.GetSender().Result; Nomenclator n = (Nomenclator)mesaj.GetTipMesaj().Result; DateTime? da = (DateTime?)mesaj.GetMessageReadDate(uid).Result; mv.MesajJson = new MesajJson(mesaj, d, s, us, n, da); mv.InvolvedParties = (Utilizator[])d.GetInvolvedParties().Result; mv.TipuriMesaj = (Nomenclator[])(new NomenclatoareRepository(uid, conStr).GetAll("tip_mesaje").Result); Mesaj[] ms = null; List <MesajJson> ls = new List <MesajJson>(); if (id != null) { d = new Dosar(uid, conStr, Convert.ToInt32(id)); ms = (Mesaj[])d.GetSentMesaje().Result; } else { Utilizator u = (Utilizator)Session["CURENT_USER"]; ms = (Mesaj[])u.GetSentMesaje(_START_LIMIT, _END_LIMIT).Result; } foreach (Mesaj m in ms) { //ls.Add(new MesajJson(m, (Dosar)m.GetDosar().Result, (Utilizator)m.GetSender().Result, (Utilizator[])m.GetReceivers().Result, (Nomenclator)m.GetTipMesaj().Result, (DateTime?)m.GetMessageReadDate(uid).Result)); MesajJson mj = new MesajJson(m); mj.DataCitire = (DateTime?)m.GetMessageReadDate(uid).Result; ls.Add(mj); } mv.MesajeJson = ls.ToArray(); //return PartialView("_MesajeView", mv); return(Json(mv, JsonRequestBehavior.AllowGet)); }