public IHttpActionResult Post5(Rol rol) { try { var rolManager = new RolManagement(); apiResponse = new ApiResponse(); var res = rolManager.RetrieveAllByUser(rol); apiResponse.Data = res; return(Ok(apiResponse)); } catch (Exception e) { return(InternalServerError(e)); } }
public IHttpActionResult Post3(Rol rol) { try { var rolManager = new RolManagement(); rolManager.Associate(rol); var apiResponse = new ApiResponse(); apiResponse.Message = "true"; return(Ok(apiResponse)); } catch (Exception e) { return(InternalServerError(e)); } }
public IHttpActionResult PostRoles(Rol rol) { try { var rolManager = new RolManagement(); apiResponse = new ApiResponse(); var res = rolManager.RetrieveAllByIdHotel(rol.Hotel); apiResponse.Data = res; apiResponse.Message = "true"; return(Ok(apiResponse)); } catch (Exception e) { return(InternalServerError(e)); } }
public IHttpActionResult Get() { try { var rolManager = new RolManagement(); apiResponse = new ApiResponse(); List <Rol> roles = rolManager.RetrieveAllPermisos(); apiResponse.Data = roles; apiResponse.Message = "true"; return(Ok(apiResponse)); } catch (Exception e) { return(InternalServerError(e)); } }
public IHttpActionResult Get(string id) { try { var rolManager = new RolManagement(); apiResponse = new ApiResponse(); var res = rolManager.RetrieveAllByIdHotel(Int32.Parse(id)); apiResponse.Data = res; apiResponse.Message = "true"; return(Ok(apiResponse)); } catch (Exception e) { return(InternalServerError(e)); } }
public IActionResult Delete(int id) { try { var rm = new RolManagement(); var c = new Rol { id = id }; rm.Delete(c); return(Ok()); } catch (Exception ex) { return(StatusCode(500, ex)); } }
public IHttpActionResult Post2(Rol rol) { try { var rolManager = new RolManagement(); Rol res = rolManager.Validate(rol); var apiResponse = new ApiResponse(); if (res == null) { apiResponse.Data = true; } else { apiResponse.Data = false; } return(Ok(apiResponse)); } catch (Exception e) { return(InternalServerError(e)); } }
public UiContainer InicioDeSesion(string objUiContainer) { var uiContainer = UiContainer.Build(objUiContainer); var managerDeUsuarios = new UserManagement(); var usuarioWEB = new User(); var managerDeRol = new RolManagement(); var rolDB = new Rol(); try { var txtCedula = uiContainer.GetCtrlModel <CtrlInputModel>("txtCedula"); var txtClave = uiContainer.GetCtrlModel <CtrlInputModel>("txtClave"); //Inicia el código de encriptación de la contraseña var ueCodigo = new UnicodeEncoding(); //Objeto para instanciar las codificación var Md5 = new MD5CryptoServiceProvider(); //Calcula el valor hash de la cadena recibida->txtPassw byte[] bHashU = Md5.ComputeHash(ueCodigo.GetBytes(txtClave.Value)); //'se toma en codigo ya encriptado del password recibido en la caja de texto //'y se iguala a una variable llamada password que es la que va a ir a //'guardarse a la BD var password = Convert.ToBase64String(bHashU); //SE IGUALA LA INSTANCIA DEL PASSWORD DEL USUARIO AL PASSWORD INTRODUCIDO DESDE EL FORM //PARA IR A HACER LA BUSCQUEDA EN LA TABLA A TRAVES DE ESE VALOR Y VERIFICAR SI LA CLAVE EXISTE //Y SI EXISTE, SI LA CLAVE PERTEN usuarioWEB.Pass_Usuario = password; usuarioWEB.IdUsuario = txtCedula.Value; //HACE LA BUSQUEDA EN LA BD, POR LO QUE VA A IR A PASAR POR TODA LA ARQUITECTURA usuarioWEB = managerDeUsuarios.Retrieve(usuarioWEB); //SI LA CLAVE NO EXISTE EN LA TABLA DE USUARIOS if (usuarioWEB == null) { uiContainer.ErrorMessage = "El usuario " + txtCedula.Value + " aún no está registrado"; } else { //CASO CONTRARIO, SI EXISTE SE VERIFICA SI LA CLAVE QUE SE ENCONTRO EN ESE REGISTRO DE LA TABLA //CONINCIDE CON LA CLAVE QUE EL USUARIO ESTÁ INGRESANDO POR TECLADO //SI CONINCIDEN ENTONCES EL USUARIO ES VALIDO var Clave = usuarioWEB.Pass_Usuario; if (Clave == password) { var rol = usuarioWEB.IdRole; rolDB.IdRol = rol; rolDB = managerDeRol.Retrieve(rolDB); //var uiContainer = UiContainer.Build(objUiContainer); if (rolDB != null) { ViewBag.Rol = rolDB.Nombre_Role; } //return uiContainer; } else { uiContainer.ErrorMessage = "La contraseña introducida es incorrecta"; } } } catch (ChallengeMeException ex) { uiContainer.ErrorMessage = ex.ErrorDescription; } return(uiContainer); }
public List <Rol> RetrieveAll() { var rm = new RolManagement(); return(rm.RetrieveAll()); }
public ActionResult Login(LoginViewModel model, string returnUrl) { var managerDeUsuarios = new UserManagement(); var usuarioWEB = new User(); var managerDeRol = new RolManagement(); var rolDB = new Rol(); var txtEmail = model.Email; var txtPassword = model.Password; //Inicia el código de encriptación de la contraseña var ueCodigo = new UnicodeEncoding(); //Objeto para instanciar las codificación var Md5 = new MD5CryptoServiceProvider(); //Calcula el valor hash de la cadena recibida->txtPassw byte[] bHashU = Md5.ComputeHash(ueCodigo.GetBytes(txtPassword)); //'se toma en codigo ya encriptado del password recibido en la caja de texto //'y se iguala a una variable llamada password que es la que va a ir a //'guardarse a la BD var Password = Convert.ToBase64String(bHashU); if (ModelState.IsValid) { //SE IGUALA LA INSTANCIA DEL PASSWORD DEL USUARIO AL PASSWORD INTRODUCIDO DESDE EL FORM //PARA IR A HACER LA BUSCQUEDA EN LA TABLA A TRAVES DE ESE VALOR Y VERIFICAR SI LA CLAVE EXISTE //Y SI EXISTE, SI LA CLAVE PERTEN usuarioWEB.Pass_Usuario = Password; usuarioWEB.Correo_Usuario = txtEmail; //HACE LA BUSQUEDA EN LA BD, POR LO QUE VA A IR A PASAR POR TODA LA ARQUITECTURA usuarioWEB = managerDeUsuarios.RetrieveByEmail(usuarioWEB); if (usuarioWEB != null) { if (usuarioWEB.Correo_Usuario.Equals(txtEmail) && usuarioWEB.Pass_Usuario.Equals(Password)) { var rol = usuarioWEB.IdRole; rolDB.IdRol = rol; rolDB = managerDeRol.Retrieve(rolDB); if (rolDB.Nombre_Role.Equals("WEB")) { Session["Rol"] = rolDB.Nombre_Role; Session["User"] = usuarioWEB.NombreUsuario; Session["Email"] = usuarioWEB.Correo_Usuario; return(Redirect(returnUrl ?? Url.Action("Index", "Account"))); } } if (usuarioWEB.Correo_Usuario.Equals(txtEmail) && usuarioWEB.Pass_Usuario.Equals(Password)) { var rol = usuarioWEB.IdRole; rolDB.IdRol = rol; rolDB = managerDeRol.Retrieve(rolDB); if (rolDB.Nombre_Role.Equals("SA") || rolDB.Nombre_Role.Equals("ORGANIZADOR")) { Session["Rol"] = rolDB.Nombre_Role; Session["User"] = usuarioWEB.NombreUsuario; Session["Email"] = usuarioWEB.Correo_Usuario; } return(Redirect(returnUrl ?? Url.Action("Index", "Account"))); } else { ModelState.AddModelError("", "Nombre de usuario o Contraseña incorrecta"); return(View()); } } else { ModelState.AddModelError("", "El usuario " + txtEmail + " no está registrado"); return(View()); } } else { return(View()); } }