public response SendToInvolvedParties() { try { response toReturn = new response(true, "", null, null, new List <Error>()); Dosar d = (Dosar)this.GetDosar().Result; Utilizator[] utilizatori = (Utilizator[])d.GetInvolvedParties().Result; foreach (Utilizator utilizator in utilizatori) { MesajUtilizator mesajUtilizator = new MesajUtilizator(authenticatedUserId, connectionString) { ID_UTILIZATOR = Convert.ToInt32(utilizator.ID), ID_MESAJ = Convert.ToInt32(this.ID) }; response r = mesajUtilizator.Insert(); if (!r.Status) { toReturn.AddResponse(r); } } return(toReturn); } catch (Exception exp) { LogWriter.Log(exp); return(new response(false, exp.ToString(), null, null, new List <Error>() { new Error(exp) })); } }
public JsonResult GetInvolvedParties(int?id) // id_dosar { 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)); response r = d.GetInvolvedParties(); return(Json(r, JsonRequestBehavior.AllowGet)); }
public JsonResult GetMessages(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"]); 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; Dosar d = new Dosar(uid, conStr, Convert.ToInt32(id)); 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); List <MesajJson> ls = new List <MesajJson>(); Mesaj[] ms = null; if (id != null) { d = new Dosar(uid, conStr, Convert.ToInt32(id)); ms = (Mesaj[])d.GetMesaje().Result; } else { Utilizator u = (Utilizator)Session["CURENT_USER"]; ms = (Mesaj[])u.GetMesaje(_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(); */ mv.MesajeJson = new MesajJson[ms.Length]; for (int i = 0; i < ms.Length; i++) { mv.MesajeJson[i] = new MesajJson(ms[i]); mv.MesajeJson[i].DataCitire = (DateTime?)ms[i].GetMessageReadDate(uid).Result; } //return PartialView("_MesajeView", mv); return(Json(mv, JsonRequestBehavior.AllowGet)); }