public HttpResponseMessage Login() { var authenticationToken = Request.Headers.Authorization.Parameter; var decodedAuthenticationToken = Encoding.UTF8.GetString(Convert.FromBase64String(authenticationToken)); var usernamePasswordArray = decodedAuthenticationToken.Split(':'); var userName = usernamePasswordArray[0]; var password = usernamePasswordArray[1]; var IP = Request.Headers.GetValues("IP").First(); Login login = new Login() { UserName = userName, Password = password }; Users LoginUser = UBL.Login(login); if (LoginUser.UserID > 0) { GeolocationStack location = GetGeolocation(IP); LoginRecord loginRecord = new LoginRecord() { UserID = LoginUser.UserID, IP = location.Ip, Country = location.CountryName, Region = location.RegionName, City = location.City }; UBL.AddLogin(loginRecord); Users Details = UBL.Details(LoginUser.UserID); //Details.RolesData = RBL.List().Where(x => x.RoleID == Details.RoleID).FirstOrDefault(); //Details.GroupList = GBL.ListbyUser(Details.UserID); var token = GenerateToken(LoginUser.UserID); if (token.TokenID.Length > 0) { Details.NeedResetPwd = LoginUser.NeedResetPwd; Details.Token = token.TokenID; Details.TokenExpires = token.ExpiresDate; Details.TokenExpiresMin = expireTime; return(this.Request.CreateResponse(HttpStatusCode.OK, Details)); } else { return(this.Request.CreateResponse(HttpStatusCode.InternalServerError)); } } else { return(this.Request.CreateResponse(HttpStatusCode.Unauthorized)); } }
public HttpResponseMessage Details(int id) { var r = UBL.Details(id); if (r.UserID > 0) { return(this.Request.CreateResponse(HttpStatusCode.OK, r)); } else { return(this.Request.CreateResponse(HttpStatusCode.InternalServerError)); } }
public ActionResult Details(int?id) { if (id == null || !UsersBL.Exists(id.Value)) { return(RedirectToAction("Index")); } return(View(UsersBL.Details(id.Value))); }
public ActionResult Edit(int?id) { if (id == null || !UsersBL.Exists(id.Value)) { return(RedirectToAction("Index")); } User editUser = UsersBL.Details(id.Value); return(View(editUser)); }
// GET: Users/Edit/1 public ActionResult Edit(int id = 0) { if ((Request.IsAuthenticated)) { Users User = UserBL.Details(id); var Roles = from r in RolesBL.Roles() where r.ActiveFlag == true select r; User.RolesList = Roles.ToList(); ViewBag.UserName = User.UserName.ToString(); return(View(User)); } else { return(this.RedirectToAction("Login", "Account")); } }
// GET: Users/Edit/1 public ActionResult Edit(int id, int AppID) { if ((Request.IsAuthenticated)) { Users User = UBL.Details(id, AppID); var Roles = from r in RBL.List(AppID) where r.ActiveFlag == true select r; User.RolesList = Roles.ToList(); string layout = "~/Views/Shared/_MinistryLayout.cshtml"; if (AppID == 2) { layout = "~/Views/Shared/_MusicLayout.cshtml"; } else { if (AppID == 3) { layout = "~/Views/Shared/_ScenicLayout.cshtml"; } else { } } ViewBag.Layout = layout; ViewBag.UserName = User.UserName.ToString(); return(View(User)); } else { return(this.RedirectToAction("Login", "Account")); } }
public async Task <ActionResult> Delete(int id) { try { await UsersBL.Delete(id); return(RedirectToAction("Index")); } catch { ModelState.AddModelError("", "No se pudo eliminar este usuario"); var user = UsersBL.Details(id); return(View(user)); } }
public UserDetailsViewModel Details(Guid id) => UsersBL.Details(id);