Пример #1
0
        public ActionResult CorreoPass(string tk)
        {
            RCAU mRCAU = new RCAU();

            //var tkRCAU = new RCAU()
            //{
            //    UTOKEN = tk
            //};

            //var res = new RCAU();
            try
            {
                mRCAU = db.RCAU.Where(m => m.UTOKEN == tk).SingleOrDefault();

                //var data = "{ 'ACCION': 'FINDTOKEN', 'Data': " + Newtonsoft.Json.JsonConvert.SerializeObject(tkRCAU) + " }";
                //var resu = fc.LlamadoApi(data, Baseurl + "RCAU/CRUD");

                //if (!resu.Contains("ERROR"))
                //{
                //    res = Newtonsoft.Json.JsonConvert.DeserializeObject<RCAU>(resu);
                //}
            }
            catch (Exception ex)
            {
                //res = "ERROR: " + ex.Message;
            }
            return(View(mRCAU));
        }
Пример #2
0
        public ActionResult ActualizaPass(MdlCambioPass model)
        {
            string res = "";

            if (!ModelState.IsValid)
            {
                foreach (var item in ModelState.Values)
                {
                    if (item.Errors.Count() > 0)
                    {
                        foreach (var row in item.Errors)
                        {
                            res = row.ErrorMessage;
                        }
                    }
                }
                return(Json(new { result = res }));
            }

            try
            {
                RCAU uRCAU = db.RCAU.Where(m => m.UTOKEN == model.Token).SingleOrDefault();
                uRCAU.UPASS           = model.Password;
                uRCAU.UTOKEN          = "";
                db.Entry(uRCAU).State = EntityState.Modified;
                db.SaveChanges();
                res = "OK";
            }
            catch (Exception ex)
            {
                res = "ERROR: " + ex.ToString();
            }

            return(Json(new { result = res }));
        }
Пример #3
0
        public ActionResult Elimina(string Id)
        {
            string Respu = "";
            var    res   = new List <RCAU>();

            try
            {
                RCAU rCAU = db.RCAU.Find(Id);


                rCAU.USTS = "Z";

                db.Entry(rCAU).State = EntityState.Modified;
                db.SaveChanges();



                //var data = "{ 'ACCION': 'BORRAR', 'Data': " + JsonConvert.SerializeObject(rCAU) + " }";
                //var resu = fc.LlamadoApi(data, Baseurl + "RCAU/CRUD");

                //if (!resu.Contains("ERROR"))
                //{
                res = db.RCAU.Where(m => m.USTS == "A" && ((m.UMOD == "SRGUSR" || m.UMOD == "ASISTENTE") || m.UTIPO == "POOLASISTENTE")).ToList();
                foreach (var item in res)
                {
                    if (item.UGRP01 != null)
                    {
                        if (item.UGRP01.Trim() != "")
                        {
                            item.UGRP01 = item.UGRP01 + "%";
                        }
                    }
                    if (item.UACC01 == 1)
                    {
                        item.Tipo = "Usuario";
                    }
                    if (item.UACC02 == 1)
                    {
                        item.Tipo = "Asistente";
                    }
                    if (item.UACC03 == 1)
                    {
                        item.Tipo = "Jefe";
                    }
                }
                SessionManager.Set("DUsuarios", res);
                Respu = "OK";
                //}
            }
            catch (Exception ex)
            {
                Respu = "ERROR: " + ex.ToString();
            }
            return(Json(new { result = Respu }));
        }
Пример #4
0
        public ActionResult CorreoPass(string tk)
        {
            RCAU mRCAU = new RCAU();

            try
            {
                mRCAU = db.RCAU.Where(m => m.UTOKEN == tk).SingleOrDefault();
            }
            catch (Exception ex)
            {
                //res = "ERROR: " + ex.Message;
            }
            return(View(mRCAU));
        }
Пример #5
0
        public ActionResult Nuevo(string Usr, string Nme, string Eml, string Tpo, int CargaUsr)
        {
            string Respu = "";
            var    nRCAU = new RCAU()
            {
                USTS    = "A",
                UTIPO   = "PEDIDOS",
                UMOD    = "PEDIDOS",
                UFECCAD = DateTime.Now,
                UUPDDAT = DateTime.Now,
                UUSR    = Usr,
                UNOM    = Nme,
                UEMAIL  = Eml,
                UACC01  = (Tpo == "1") ? 1 : 0, //USUARIO
                UACC02  = (Tpo == "2") ? 1 : 0, //ASISTENTE
                UACC03  = (Tpo == "3") ? 1 : 0, //JEFE
                UGRP01  = CargaUsr.ToString() + "0"
            };
            var res = new List <RCAU>();

            try
            {
                db.RCAU.Add(nRCAU);
                db.SaveChanges();



                //var data = "{ 'ACCION': 'CREAR', 'Data': " + JsonConvert.SerializeObject(nRCAU) + " }";
                //var resu = fc.LlamadoApi(data, Baseurl + "RCAU/CRUD");

                //if (!resu.Contains("ERROR"))
                //{
                res = db.RCAU.Where(m => m.USTS == "A" && ((m.UMOD == "SRGUSR" || m.UMOD == "ASISTENTE") || m.UTIPO == "POOLASISTENTE")).ToList();
                foreach (var item in res)
                {
                    if (item.UGRP01 != null)
                    {
                        if (item.UGRP01.Trim() != "")
                        {
                            item.UGRP01 = item.UGRP01 + "%";
                        }
                    }
                    if (item.UACC01 == 1)
                    {
                        item.Tipo = "Usuario";
                    }
                    if (item.UACC02 == 1)
                    {
                        item.Tipo = "Asistente";
                    }
                    if (item.UACC03 == 1)
                    {
                        item.Tipo = "Jefe";
                    }
                }
                SessionManager.Set("DUsuarios", res);
                Respu = "OK";
                //}
            }
            catch (Exception ex)
            {
                Respu = "ERROR: " + ex.ToString();
            }
            return(Json(new { result = Respu }));
        }
Пример #6
0
        public JsonResult Logueo(MdlLogin model, string returnUrl, string donde)
        {
            var res  = new RCAU();
            var resu = "";

            try
            {
                res = db.RCAU.Where(m => m.UUSR == model.User && m.USTS == "A" && (m.UTIPO == "POOLASISTENTE" || (m.UMOD == "SRGUSR" || m.UMOD == "ASISTENTE"))).SingleOrDefault();
                if (res != null)
                {
                    if (res.UPASS == model.Password)
                    {
                        //if (res.UACC03 == 1)
                        //{
                        //    res.UMOD = "JEFE";
                        //}
                        SessionManager.Set("VarUsuario", res);
                        resu = "OK";
                    }
                    else
                    {
                        resu = "La contraseña es incorrecta";
                    }
                }
                else
                {
                    resu = "Usuario no existe";
                }
            }
            catch (Exception ex)
            {
                //res = "ERROR: " + ex.Message;
            }

            var tipousr = "";

            if (resu == "OK")
            {
                if (res.UACC01 == null || res.UACC01 == 1)
                {
                    tipousr = "******";
                }

                if (res.UACC02 == 1)
                {
                    tipousr = "******";
                }

                if (res.UACC03 == 1)
                {
                    tipousr = "******";
                }

                if (res.UACC04 == 1)
                {
                    tipousr = "******";
                }
            }


            return(Json(new { result = resu, redir = donde, Tipo = tipousr }));
        }
Пример #7
0
        public JsonResult Logueo(MdlLogin model, string returnUrl, string donde)
        {
            RCAU          mRCAU = new RCAU();
            string        res   = "";
            StringBuilder Error = new StringBuilder();

            try
            {
                mRCAU = db.RCAU.Where(m => m.UUSR == model.User && m.USTS == "A").SingleOrDefault();
                if (res != null)
                {
                    if (mRCAU.UPASS == model.Password)
                    {
                        SessionManager.Set("VarUsuario", res);
                        res = "OK";
                    }
                    else
                    {
                        res = "La contraseña es incorrecta";
                    }
                }
                else
                {
                    res = "Usuario no existe";
                }
            }
            catch (DbEntityValidationException ex)
            {
                Error.AppendLine(ex.ToString());
                foreach (var eve in ex.EntityValidationErrors)
                {
                    Error.AppendLine("");
                    Error.AppendFormat("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State);
                    Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State);
                    foreach (var ve in eve.ValidationErrors)
                    {
                        Error.AppendLine("");
                        Error.AppendFormat("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage);
                        Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage);
                    }
                }
                res = "ERROR: " + Error.ToString();
            }
            catch (Exception ex)
            {
                res = "ERROR: " + ex.ToString() + ((ex.InnerException != null) ? ex.InnerException.ToString() : "");
            }

            var tipousr = "";

            //if (resu == "OK")
            //{
            //    if (res.UACC01 == null || res.UACC01 == 1)
            //    {
            //        tipousr = "******";
            //    }

            //    if (res.UACC02 == 1)
            //    {
            //        tipousr = "******";
            //    }

            //    if (res.UACC03 == 1)
            //    {
            //        tipousr = "******";
            //    }

            //    if (res.UACC04 == 1)
            //    {
            //        tipousr = "******";
            //    }
            //}


            return(Json(new { result = res, redir = donde, Tipo = tipousr }));
        }