Example #1
0
        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));
        }