コード例 #1
0
        public async Task <ActionResult> AutoCompleteTrabajador(string term /*our key word*/)
        {
            var lUsuarios = await MantenimientoPCL.ListarUsuarios();

            if (lUsuarios.Code != 200)
            {
                throw new Exception(lUsuarios.Message);
            }
            int Acc = lUsuarios.Data.lresponse.Count();

            string[] items = new string[Acc];
            int      i     = 0;

            foreach (ResponseLoginBE g in lUsuarios.Data.lresponse)
            {
                items[i] = string.Format("{0}", g.DNI);
                i        = i + 1;
            }
            //we did a fetch of term from items
            var filteredItems = items.Where(
                item => item.IndexOf(term, StringComparison.InvariantCultureIgnoreCase) >= 0);

            //we return a json data
            return(Json(filteredItems, JsonRequestBehavior.AllowGet));
        }
コード例 #2
0
        public async Task <ActionResult> PerfilUsuario()
        {
            if (Session[Sesiones.UsuarioLogin] == null)
            {
                Session.Clear();
                return(RedirectToAction("Index", "Login"));
            }

            try
            {
                var Usuariores = (BaseModel)Session[Sesiones.UsuarioLogin];
                ViewBag.Message = ObjMessage;
                ObjMessage      = null;

                var datos = await MantenimientoPCL.GetUsuarioById(Usuariores.Usuario.IdUsuario);

                if (datos.Code != 200)
                {
                    throw new Exception(datos.Message);
                }

                ResponseLoginBE           duModel = datos.Data.response;
                MantenimientoUsuarioModel muModel = new MantenimientoUsuarioModel();
                muModel.Usuario = datos.Data.response;
                return(View(muModel));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #3
0
        public async Task <PartialViewResult> DeleteUsuario(int id)
        {
            try
            {
                var perfiles = await PerfilPCL.ListarPerfiles();

                if (perfiles.Code != 200)
                {
                    throw new Exception(perfiles.Message);
                }
                if (perfiles.Data == null)
                {
                    throw new Exception("Error al intentar cargar perfiles");
                }

                List <PerfilBE> lPerfiles = new List <PerfilBE>();
                lPerfiles.AddRange(perfiles.Data);

                var datos = await MantenimientoPCL.GetUsuarioById(id);

                if (datos.Code != 200)
                {
                    throw new Exception(datos.Message);
                }

                ResponseLoginBE duModel = datos.Data.response;

                return(PartialView("_DeleteUsuario", duModel));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #4
0
        public async Task <ActionResult> Usuarios()
        {
            if (Session[Sesiones.UsuarioLogin] == null)
            {
                Session.Clear();
                return(RedirectToAction("Index", "Login"));
            }

            try
            {
                var Usuariores = (BaseModel)Session[Sesiones.UsuarioLogin];

                var lUsuarios = await MantenimientoPCL.ListarUsuarios();

                if (lUsuarios.Code != 200)
                {
                    throw new Exception(lUsuarios.Message);
                }

                MantenimientoUsuarioModel muModel = new MantenimientoUsuarioModel()
                {
                    Usuario   = Usuariores.Usuario,
                    lUsuarios = lUsuarios.Data.lresponse
                };
                ViewBag.Message = ObjMessage;
                ObjMessage      = null;
                return(View(muModel));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #5
0
        public async Task <ActionResult> RegistrarDoctor()
        {
            if (Session[Sesiones.UsuarioLogin] == null)
            {
                Session.Clear();
                return(RedirectToAction("Index", "Login"));
            }

            var lDoctor = await MantenimientoPCL.ListarDoctores();

            if (lDoctor.Code != 200)
            {
                throw new Exception(lDoctor.Message);
            }
            if (lDoctor.Data == null)
            {
                throw new Exception("Error al intentar cargar perfiles");
            }

            var duModel = new DoctorBE.ResponseDoctoreBE
            {
                DNIdoctor  = "",
                Specialism = "",
                CMP        = "",
                RENumber   = "",
                Activo     = true,
                Company    = 1,
                lEmpresa   = lDoctor.Data.lresponse.FirstOrDefault().lEmpresa,
                lUsuario   = lDoctor.Data.lresponse.FirstOrDefault().lUsuario
            };

            return(PartialView("_RegistrarDoctor", duModel));
        }
コード例 #6
0
        public async Task <ActionResult> RegistrarUsuario(ResponseLoginBE duModel)
        {
            if (Session[Sesiones.UsuarioLogin] == null)
            {
                Session.Clear();
                return(RedirectToAction("Index", "Login"));
            }

            try
            {
                if (ModelState.IsValid)
                {
                    var Usuariores = (BaseModel)Session[Sesiones.UsuarioLogin];

                    var nuevo = new ResponseLoginBE
                    {
                        IdUsuario = duModel.IdUsuario,
                        DNI       = duModel.DNI,
                        Name      = duModel.Name,
                        LastName1 = duModel.LastName1,
                        LastName2 = duModel.LastName2,
                        Type      = duModel.Type,
                        Mobile    = "1",
                        Password  = duModel.Password,
                        Email     = duModel.Email
                    };
                    var registrar = await MantenimientoPCL.RegistrarUsuario(nuevo);

                    if (registrar.Code != 200)
                    {
                        throw new Exception(registrar.Message);
                    }
                    ObjMessage = new MessageDialog()
                    {
                        Title   = "Se registro correctamente el usuario.",
                        Estado  = 0,
                        Message = registrar.Data.Message
                    };
                    if (registrar.Data.Codigo != 0)
                    {
                        ObjMessage.Title  = "Error al intentar registrar el nuevo usuario";
                        ObjMessage.Estado = registrar.Data.Codigo;
                    }
                }

                return(RedirectToAction("Usuarios", "Usuario"));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #7
0
        public async Task <ActionResult> PerfilUsuario(MantenimientoUsuarioModel duModel)
        {
            if (Session[Sesiones.UsuarioLogin] == null)
            {
                Session.Clear();
                return(RedirectToAction("Index", "Login"));
            }

            try
            {
                var Usuariores = (BaseModel)Session[Sesiones.UsuarioLogin];
                var modificado = new ResponseLoginBE
                {
                    IdUsuario = duModel.Usuario.IdUsuario,
                    DNI       = duModel.Usuario.DNI,
                    Name      = duModel.Usuario.Name,
                    LastName1 = duModel.Usuario.LastName1,
                    LastName2 = duModel.Usuario.LastName2,
                    Type      = duModel.Usuario.Type,
                    Mobile    = "1",
                    Password  = duModel.Usuario.Password,
                    Activo    = duModel.Usuario.Activo,
                    Email     = duModel.Usuario.Email
                };
                var guardar = await MantenimientoPCL.ModificarUsuario(modificado);

                if (guardar.Code != 200)
                {
                    throw new Exception(guardar.Message);
                }
                ModelState.Clear();

                ObjMessage = new MessageDialog()
                {
                    Title   = "Se modificó correctamente el usuario.",
                    Estado  = 0,
                    Message = guardar.Data.Message
                };
                if (guardar.Data.Codigo != 0)
                {
                    ObjMessage.Title  = "Error al intentar modificar el usuario";
                    ObjMessage.Estado = guardar.Data.Codigo;
                }
                return(RedirectToAction(duModel.Usuario.Mobile));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #8
0
        public async Task <ActionResult> RegistrarDoctor(DoctorBE.ResponseDoctoreBE duModel)
        {
            if (Session[Sesiones.UsuarioLogin] == null)
            {
                Session.Clear();
                return(RedirectToAction("Index", "Login"));
            }

            try
            {
                if (ModelState.IsValid)
                {
                    var Usuariores = (BaseModel)Session[Sesiones.UsuarioLogin];

                    var nuevo = new DoctorBE.ResponseDoctoreBE
                    {
                        DNIdoctor  = duModel.DNIdoctor,
                        Specialism = duModel.Specialism,
                        CMP        = duModel.CMP,
                        RENumber   = duModel.RENumber,
                        Activo     = true,
                        Company    = duModel.Company
                    };
                    var registrar = await MantenimientoPCL.RegistrarDoctor(nuevo);

                    if (registrar.Code != 200)
                    {
                        throw new Exception(registrar.Message);
                    }
                    ObjMessage = new MessageDialog()
                    {
                        Title   = "Se registro correctamente el usuario.",
                        Estado  = 0,
                        Message = registrar.Data.Message
                    };
                    if (registrar.Data.Codigo != 0)
                    {
                        ObjMessage.Title  = "Error al intentar registrar el nuevo usuario";
                        ObjMessage.Estado = registrar.Data.Codigo;
                    }
                }
                return(RedirectToAction("Doctores", "Doctor"));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #9
0
        public async Task <ActionResult> DatosDoctor(DoctorBE.ResponseDoctoreBE duModel)
        {
            if (Session[Sesiones.UsuarioLogin] == null)
            {
                Session.Clear();
                return(RedirectToAction("Index", "Login"));
            }

            try
            {
                var Usuariores = (BaseModel)Session[Sesiones.UsuarioLogin];
                var modificado = new DoctorBE.ResponseDoctoreBE
                {
                    IdDoctor     = duModel.IdDoctor
                    , DNIdoctor  = duModel.DNIdoctor
                    , Specialism = duModel.Specialism
                    , CMP        = duModel.CMP
                    , RENumber   = duModel.RENumber
                    , Company    = duModel.Company
                    , Activo     = duModel.Activo
                };

                var guardar = await MantenimientoPCL.ModificarDoctor(modificado);

                if (guardar.Code != 200)
                {
                    throw new Exception(guardar.Message);
                }
                ModelState.Clear();
                ObjMessage = new MessageDialog()
                {
                    Title   = "Se modificó correctamente el usuario.",
                    Estado  = 0,
                    Message = guardar.Data.Message
                };
                if (guardar.Data.Codigo != 0)
                {
                    ObjMessage.Title  = "Error al intentar modificar el usuario";
                    ObjMessage.Estado = guardar.Data.Codigo;
                }
                return(RedirectToAction("Doctores"));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #10
0
        public async Task <PartialViewResult> DatosUsuario(int id)
        {
            try
            {
                var datos = await MantenimientoPCL.GetUsuarioById(id);

                if (datos.Code != 200)
                {
                    throw new Exception(datos.Message);
                }

                ResponseLoginBE duModel = datos.Data.response;

                return(PartialView("_DatosUsuario", duModel));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #11
0
        public async Task <PartialViewResult> DatosDoctor(int id)
        {
            try
            {
                var datos = await MantenimientoPCL.GetDoctorById(id);

                if (datos.Code != 200)
                {
                    throw new Exception(datos.Message);
                }

                DoctorBE.ResponseDoctoreBE duModel = datos.Data.response;

                return(PartialView("_DatosDoctor", duModel));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #12
0
        public async Task <ActionResult> DeleteUsuario(ResponseLoginBE duModel)
        {
            if (Session[Sesiones.UsuarioLogin] == null)
            {
                Session.Clear();
                return(RedirectToAction("Index", "Login"));
            }
            try
            {
                var Usuariores = (BaseModel)Session[Sesiones.UsuarioLogin];
                var modificado = new ResponseLoginBE
                {
                    IdUsuario = duModel.IdUsuario,
                    Activo    = duModel.Activo
                };

                var guardar = await MantenimientoPCL.ModificarUsuario(modificado);

                if (guardar.Code != 200)
                {
                    throw new Exception(guardar.Message);
                }
                ModelState.Clear();
                ObjMessage = new MessageDialog()
                {
                    Title   = "Se eliminó correctamente el usuario.",
                    Estado  = 0,
                    Message = guardar.Data.Message
                };
                if (guardar.Data.Codigo != 0)
                {
                    ObjMessage.Title  = "Error al intentar eliminar el usuario";
                    ObjMessage.Estado = guardar.Data.Codigo;
                }
                return(RedirectToAction("Usuarios"));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }