Пример #1
0
        public JsonResult Edit(Sentinta Sentinta)
        {
            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"]);

            if (Sentinta.ID == null) // insert
            {
                Sentinta       p   = new Sentinta(_CURENT_USER_ID, conStr);
                PropertyInfo[] pis = Sentinta.GetType().GetProperties();
                foreach (PropertyInfo pi in pis)
                {
                    pi.SetValue(p, pi.GetValue(Sentinta));
                }
                toReturn = p.Insert();
            }
            else //
            {
                Sentinta p = new Sentinta(_CURENT_USER_ID, conStr, Convert.ToInt32(Sentinta.ID));
                string   s = JsonConvert.SerializeObject(Sentinta, Formatting.None, new Newtonsoft.Json.Converters.IsoDateTimeConverter()
                {
                    DateTimeFormat = CommonFunctions.DATE_FORMAT
                });
                toReturn = p.Update(s);
            }
            return(Json(toReturn, JsonRequestBehavior.AllowGet));
        }
Пример #2
0
        public JsonResult Delete(int id)
        {
            response r               = new response();
            string   conStr          = Session["conStr"].ToString(); //ConfigurationManager.ConnectionStrings["MySQLConnectionString"].ConnectionString;
            int      _CURENT_USER_ID = Convert.ToInt32(Session["CURENT_USER_ID"]);
            //DosareRepository dr = new DosareRepository(_CURENT_USER_ID, conStr);
            Sentinta s = new Sentinta(_CURENT_USER_ID, conStr, id);

            r = s.Delete();
            return(Json(r, JsonRequestBehavior.AllowGet));
        }
Пример #3
0
        //[AuthorizeUser(ActionName = "Dosare", Recursive = false)]
        public JsonResult ImportSedintaPortal(int IdSedintaPortal, ProcesStadiu ProcesStadiu, Sentinta Sentinta)
        {
            response r      = new response();
            string   conStr = Session["conStr"].ToString(); //ConfigurationManager.ConnectionStrings["MySQLConnectionString"].ConnectionString;
            int      uid    = Convert.ToInt32(Session["CURENT_USER_ID"]);

            if (Sentinta.NR_SENTINTA != null && Sentinta.DATA_SENTINTA != null)
            {
                Sentinta       s    = new Sentinta(uid, conStr);
                PropertyInfo[] pis1 = Sentinta.GetType().GetProperties();
                foreach (PropertyInfo pi in pis1)
                {
                    pi.SetValue(s, pi.GetValue(Sentinta));
                }
                r = s.Insert();
                if (r.Status)
                {
                    ProcesStadiu.ID_SENTINTA = r.InsertedId;
                }
            }
            ProcesStadiu ps = new ProcesStadiu(uid, conStr);

            PropertyInfo[] pis = ProcesStadiu.GetType().GetProperties();
            foreach (PropertyInfo pi in pis)
            {
                pi.SetValue(ps, pi.GetValue(ProcesStadiu));
            }
            r = ps.Insert();
            if (r.Status)
            {
                try
                {
                    SedintaPortal sp = new SedintaPortal(uid, conStr, IdSedintaPortal);
                    sp.Delete();
                }
                catch (Exception exp) { LogWriter.Log(exp); }
            }
            return(Json(r, JsonRequestBehavior.AllowGet));
        }
Пример #4
0
        public JsonResult Edit(ProcesStadiuExtended ProcesStadiuExtended)
        {
            response     toReturn = new response();
            string       conStr   = Session["conStr"].ToString(); //ConfigurationManager.ConnectionStrings["MySQLConnectionString"].ConnectionString;
            int          uid      = Convert.ToInt32(Session["CURENT_USER_ID"]);
            Sentinta     s        = null;
            ProcesStadiu ps       = null;

            if (ProcesStadiuExtended != null)
            {
                if (ProcesStadiuExtended.Sentinta != null && ProcesStadiuExtended.ProcesStadiu.ID_SENTINTA != null)
                {
                    s = new Sentinta(uid, conStr);
                    PropertyInfo[] pis = ProcesStadiuExtended.Sentinta.GetType().GetProperties();
                    foreach (PropertyInfo pi in pis)
                    {
                        pi.SetValue(s, pi.GetValue(ProcesStadiuExtended.Sentinta));
                    }
                }

                ps = new ProcesStadiu(uid, conStr);
                PropertyInfo[] pis2 = ProcesStadiuExtended.ProcesStadiu.GetType().GetProperties();
                foreach (PropertyInfo pi in pis2)
                {
                    pi.SetValue(ps, pi.GetValue(ProcesStadiuExtended.ProcesStadiu));
                }
            }
            if (ps.ID == null) // insert
            {
                if (!ProcesStadiuExtended.Stadiu.STADIU_CU_SENTINTA)
                {
                    ps.ID_SENTINTA = null;
                    s = null;
                }
                if (s != null)
                {
                    toReturn = s.Insert();
                }
                if (s == null || toReturn.Status)
                {
                    toReturn         = ps.Insert();
                    toReturn.Message = JsonConvert.SerializeObject(new ProcesStadiuExtended(ps), Formatting.None, new Newtonsoft.Json.Converters.IsoDateTimeConverter()
                    {
                        DateTimeFormat = CommonFunctions.DATE_FORMAT
                    });
                }
            }
            else //update
            {
                ProcesStadiu existingPS = new ProcesStadiu(uid, conStr, Convert.ToInt32(ps.ID));
                if (!ProcesStadiuExtended.Stadiu.STADIU_CU_SENTINTA)
                {
                    ps.ID_SENTINTA = null;
                }
                if (existingPS.ID_SENTINTA != null && ps.ID_SENTINTA != null)
                {
                    toReturn = s.Update();
                }
                if (existingPS.ID_SENTINTA == null && ps.ID_SENTINTA != null)
                {
                    toReturn = s.Insert();
                    if (toReturn.Status)
                    {
                        ps.ID_SENTINTA = toReturn.InsertedId;
                    }
                }
                if (existingPS.ID_SENTINTA != null && ps.ID_SENTINTA == null)
                {
                    if (s != null)
                    {
                        toReturn = s.Delete();
                    }
                }

                if (toReturn.Status)
                {
                    toReturn         = ps.Update();
                    toReturn.Message = JsonConvert.SerializeObject(new ProcesStadiuExtended(ps), Formatting.None, new Newtonsoft.Json.Converters.IsoDateTimeConverter()
                    {
                        DateTimeFormat = CommonFunctions.DATE_FORMAT
                    });
                }
            }

            return(Json(toReturn, JsonRequestBehavior.AllowGet));
        }