示例#1
0
        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));
        }
示例#2
0
        public JsonResult Edit(UtilizatorDosar[] UtilizatoriDosare)
        {
            response toReturn       = new response(true, "", null, null, new List <Error>());
            string   conStr         = Session["conStr"].ToString(); //ConfigurationManager.ConnectionStrings["MySQLConnectionString"].ConnectionString;
            int      curent_user_id = Convert.ToInt32(Session["CURENT_USER_ID"]);

            foreach (UtilizatorDosar udP in UtilizatoriDosare)
            {
                Dosar           d  = new Dosar(curent_user_id, conStr, udP.ID_DOSAR);
                UtilizatorDosar ud = new UtilizatorDosar(curent_user_id, conStr);
                ud.ID_UTILIZATOR = udP.ID_UTILIZATOR;
                ud.ID_DOSAR      = udP.ID_DOSAR;
                response r = ud.Insert();
                if (!r.Status)
                {
                    toReturn.AddResponse(r);
                }
                else
                {
                    Mesaj    m  = new Mesaj(curent_user_id, conStr, ud.ID_DOSAR, DateTime.Now, String.Format("DOSAR NOU ({0})", d.NR_DOSAR_CASCO), String.Format("DOSAR NOU ({0})", d.NR_DOSAR_CASCO), "DOSAR NOU", curent_user_id, (int)Importanta.Low);
                    response rm = m.Insert();
                    if (rm.Status && rm.InsertedId != null)
                    {
                        m.ID = rm.InsertedId;
                        MesajUtilizator mu = new MesajUtilizator(curent_user_id, conStr);
                        mu.ID_MESAJ      = Convert.ToInt32(m.ID);
                        mu.ID_UTILIZATOR = ud.ID_UTILIZATOR;
                        response rmu = mu.Insert();
                        if (!rmu.Status)
                        {
                            toReturn.AddResponse(rmu);
                        }
                    }
                    else
                    {
                        toReturn.AddResponse(rm);
                    }
                }
            }
            return(Json(toReturn, JsonRequestBehavior.AllowGet));
        }