public bool UpdateAdmin(Guid userid, string img_path, string username, string firstname, string lastname, string address, string city, string state, string country) { dbContext = new MyProjectDataContext(); var q = from a in dbContext.AdminProfiles where a.UserId == userid select a; if (q.Any()) { AdminProfile ap = new AdminProfile(); ap.Address = address; ap.City = city; ap.Country = country; ap.FirstName = firstname; ap.LastName = lastname; ap.State = state; ap.Updated = DateTime.Now; ap.UpdatedBy = username; ap.UserId = userid; ap.UserImgPath = img_path; ap.Username = username; try { dbContext.AdminProfiles.InsertOnSubmit(ap); dbContext.SubmitChanges(); return(true); } catch { return(false); } } return(false); }
// Getting Admin Profile and display public JsonResult GetProfile() { Models.AdminProfile profile = new AdminProfile(); string LiveAdmin = Session["AdminUserName"].ToString(); DataSet data = profile.getProfileDetails(LiveAdmin); List <AdminProfile> profileList = new List <AdminProfile>(); foreach (DataRow dr in data.Tables[0].Rows) { profileList.Add(new AdminProfile { Admin_FullName = dr["Admin_FullName"].ToString(), Admin_UserName = dr["Admin_UserName"].ToString(), Admin_Email = dr["Admin_Email"].ToString(), Admin_Contact = dr["Admin_Contact"].ToString(), Admin_DOB = Convert.ToDateTime(dr["Admin_DOB"]), Admin_City = dr["Admin_City"].ToString(), Admin_State = dr["Admin_State"].ToString(), Admin_Country = dr["Admin_Country"].ToString(), Admin_Pin = Convert.ToInt32(dr["Admin_Pin"]) }); } return(Json(profileList, JsonRequestBehavior.AllowGet)); }
public bool AddAdmin(Guid userid, string username) { dbContext = new MyProjectDataContext(); string imgPath = "~/admin/dist/img/male-user.png"; AdminProfile ap = new AdminProfile(); ap.UserId = userid; ap.Username = username; ap.Created = DateTime.Now; ap.Updated = DateTime.Now; ap.UpdatedBy = username; ap.UserImgPath = imgPath; ap.Rejected = false; try { dbContext.AdminProfiles.InsertOnSubmit(ap); dbContext.SubmitChanges(); return(true); } catch (Exception ex) { throw ex; } return(false); }
public static string AddAdmininDB(AdminManageDetail _newuser) { GuruETC.DB.GuruETCEntities _etc = new DB.GuruETCEntities(); string msg = string.Empty; MembershipCreateStatus sts; try { Membership.CreateUser(_newuser.UserName, _newuser.Password, _newuser.Email, null, null, true, out sts); if (sts == MembershipCreateStatus.Success) { MembershipUser _getUser = Membership.GetUser(_newuser.UserName); if (_getUser != null) { Roles.AddUserToRole(_getUser.UserName, "Admin"); AdminProfile _prof = new AdminProfile() { UserGuid = (Guid)_getUser.ProviderUserKey, DOB = DateTime.Parse(_newuser.ADOB), Name = _newuser.UserName }; _etc.AddToAdminProfiles(_prof); _etc.SaveChanges(); msg = "Success"; } } } catch (Exception ex) { throw ex; } return(msg); }
private void AdminHome_Click(object sender, EventArgs e) { AdminProfile adminHome = new AdminProfile(); adminHome.Show(); Hide(); }
internal void Update(AdminProfile adminProfile) { AdminId = adminProfile.AdminId; FirstName = adminProfile.FirstName; LastName = adminProfile.LastName; PhoneNumber = adminProfile.PhoneNumber; Company = adminProfile.Company; Department = adminProfile.Department; JobTitle = adminProfile.JobTitle; }
private void SetCookie(AdminProfile adminProfile) { HttpCookie cookieName = new HttpCookie("userId", adminProfile.userId); HttpCookie cookiePasswod = new HttpCookie("password", adminProfile.Password); cookieName.Expires = DateTime.Now.AddDays(3); cookiePasswod.Expires = DateTime.Now.AddDays(3); Response.Cookies.Add(cookieName); Response.Cookies.Add(cookiePasswod); }
public void UpdateProfile(string username, ProfileProperties profileProperties) { MembershipUser memberUser = Membership.GetUser(username); if (memberUser == null) { throw new AggregateException("There is not found username in member."); } IMemberProfile adminProfile = new AdminProfile(ProfileBase.Create(username)); adminProfile.Setting(profileProperties); }
public string UpdateLinkSort(string sorts) { string adminName = PEContext.Current.Admin.AdminName; AdminProfileInfo adminProfile = AdminProfile.GetAdminProfile(adminName); adminProfile.AdminName = adminName; if (!adminProfile.IsNull) { adminProfile.QuickLinksConfig = sorts; AdminProfile.Update(adminProfile); return("ok"); } return("err"); }
public async Task <AdminProfileErrorCodes> UpdateAsync(AdminProfile adminProfile) { var result = await _adminProfileRepository.UpdateAsync(adminProfile); if (result == AdminProfileErrorCodes.None) { _log.Info("Admin profile updated", context: $"adminId: {adminProfile.AdminId}"); } else { _log.Info("An error occurred while updating admin profile", context: $"adminId: {adminProfile.AdminId}; error: {result}"); } return(result); }
public ActionResult Create(string username, string password) { string usr = (string.IsNullOrEmpty(username) ? (char?)null : username[0]).ToString(); if (usr.Equals("S")) { Student student = this.repository.GetStudent(username, password); if (student != null) { return(RedirectToAction("Index", "StudentOwn", new { area = "" })); } AdminProfile admin = this.repository.GetAdmin(username, password); if (admin != null) { Session["User"] = username; Session.Timeout = 10; return(RedirectToAction("Index", "AdminHome", new { area = "" })); } } else if (usr.Equals("E")) { Employee employee = this.repository.GetEmployee(username, password); if (employee != null) { return(RedirectToAction("Index", "EmployeeOwn", new { area = "" })); } AdminProfile admin = this.repository.GetAdmin(username, password); if (admin != null) { Session["User"] = username; Session.Timeout = 10; return(RedirectToAction("Index", "AdminHome", new { area = "" })); } } else { AdminProfile admin = this.repository.GetAdmin(username, password); if (admin != null) { Session["User"] = username; Session.Timeout = 10; return(RedirectToAction("Index", "AdminHome", new { area = "" })); } } ViewBag.ErrorMessage = "Username and Password Doesn't Match"; return(View()); }
protected void TxtEditor_TextChanged(object sender, EventArgs e) { base.Session["AdminNoteText"] = this.TxtEditor.Text; string adminName = PEContext.Current.Admin.AdminName; AdminProfileInfo adminProfile = AdminProfile.GetAdminProfile(adminName); adminProfile.NoteText = this.TxtEditor.Text; if (!adminProfile.IsNull) { AdminProfile.Update(adminProfile); } else { adminProfile.AdminName = adminName; AdminProfile.Add(adminProfile); } }
public string AddLink(string id) { string adminName = PEContext.Current.Admin.AdminName; AdminProfileInfo adminProfile = AdminProfile.GetAdminProfile(adminName); adminProfile.AdminName = adminName; Collection <string> quickLinksConfigCollection = this.ConvertToCollection(adminProfile.QuickLinksConfig); if (quickLinksConfigCollection.Contains(id)) { return("false"); } if (!adminProfile.IsNull) { quickLinksConfigCollection.Add(id); adminProfile.QuickLinksConfig = this.ConvertToString(quickLinksConfigCollection); AdminProfile.Update(adminProfile); } else { string str2; XmlDocument document = new XmlDocument(); HttpContext current = HttpContext.Current; if (current != null) { str2 = current.Server.MapPath("~/Admin/Common/QuickLinks.xml"); } else { str2 = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Admin/Common/QuickLinks.xml"); } document.Load(str2); foreach (XmlNode node in document.SelectNodes("/Links//Link[@IsDefalutShow='true']")) { if (this.CheckPermission(node.Attributes["operateCode"].Value)) { quickLinksConfigCollection.Add(node.Attributes["id"].Value); } } quickLinksConfigCollection.Add(id); adminProfile.QuickLinksConfig = this.ConvertToString(quickLinksConfigCollection); AdminProfile.Add(adminProfile); } return("true"); }
private void InitRptMenu() { AdminProfileInfo adminProfile = AdminProfile.GetAdminProfile(PEContext.Current.Admin.AdminName); if (!adminProfile.IsNull && (adminProfile.QuickLinksConfig != null)) { string[] strArray = adminProfile.QuickLinksConfig.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); this.RptMenu.DataSource = strArray; this.RptMenu.ItemDataBound += new RepeaterItemEventHandler(this.RptMenu_AdminConfigItemDataBound); this.RptMenu.DataBind(); } else { this.RptMenu.DataSource = this.xmlDoc.SelectNodes("/Links//Link[@IsDefalutShow='true']"); this.RptMenu.ItemDataBound += new RepeaterItemEventHandler(this.RptMenu_DefaultConfigItemDataBound); this.RptMenu.DataBind(); } }
public ActionResult Login(FormCollection form) { if (ModelState.IsValid) { string name = form["name"]; string password = form["pwd"]; string logintype = form["ltype"]; List <Admin> user = new List <Admin>(); DataAccessCredentials dac = new DataAccessCredentials(); AdminProfile ap = new AdminProfile(); user = ap.LoginCheck(name, name, password, logintype); if (user != null) { return(this.RedirectToAction("Main", "Admin")); } } return(View()); }
public ActionResult Edit(AdminProfile profile) { if (Session["User"] != null) { if (ModelState.IsValid) { this.repository.Update(profile); return(RedirectToAction("Index")); } else { return(View("profile")); } } else { return(RedirectToAction("Create", "Login")); } }
public string DeleteLink(string id) { AdminProfileInfo adminProfile = AdminProfile.GetAdminProfile(PEContext.Current.Admin.AdminName); if (adminProfile.IsNull) { return("false"); } Collection <string> quickLinksConfigCollection = this.ConvertToCollection(adminProfile.QuickLinksConfig); if (!quickLinksConfigCollection.Contains(id)) { return("false"); } quickLinksConfigCollection.Remove(id); adminProfile.QuickLinksConfig = this.ConvertToString(quickLinksConfigCollection); AdminProfile.Update(adminProfile); return("true"); }
public async Task GetInvalidUsernameAndPassword() { var options = new DbContextOptionsBuilder <AdminDbContext>() .UseSqlServer("Data Source=LAPTOP-U3V1724K;Initial Catalog=Microservices.Admin.Database;Integrated Security=True") .Options; var dbContext = new AdminDbContext(options); var adminProfile = new AdminProfile(); var configuration = new MapperConfiguration(cfg => cfg.AddProfile(adminProfile)); var mapper = new Mapper(configuration); var adminService = new AdminService(null, dbContext, mapper); var admin = await adminService.GetUsernameAndPassword(); Assert.False(admin.Name == "wrongname"); Assert.False(admin.Username == "wrongusername"); Assert.False(admin.Password == "wrongpassword"); }
protected void BtnChangeTheme_Click(object sender, EventArgs e) { string adminName = PEContext.Current.Admin.AdminName; AdminProfileInfo adminProfile = AdminProfile.GetAdminProfile(adminName); adminProfile.AdminName = adminName; adminProfile.Theme = base.Request["Theme"]; if (!adminProfile.IsNull) { AdminProfile.Update(adminProfile); } else { AdminProfile.Add(adminProfile); } this.Session.Add("AdminPage_StyleSheetTheme", base.Request["Theme"]); this.Session["IndexRightUrl"] = "Profile/ChangeTheme.aspx"; base.Response.Write("<script type='text/javascript'>parent.location.reload()</script>"); }
public ActionResult AdminProfile() { try { using (var context = new JustHallAtumationEntities()) { AdminProfile adminProfiles = (from user in context.Users join userim in context.UserImages on user.UserId equals userim.UserId select new AdminProfile() { user = user, userImage = userim }).FirstOrDefault(); return(View(adminProfiles)); } } catch (Exception ex) { return(View(ex)); } }
private void BtnBack_Click_1(object sender, RoutedEventArgs e) { // if page loaded from profile it will back to profile if (isFromProfile == true) { apr = new AdminProfile(id, mv, null); mv.MenuPage.Content = apr; apr.ShowProfileData(id).ConfigureAwait(false); Console.WriteLine("<<<<<<<<<<<<<<<<<<<< From Profilr"); //apr.LoadData().ConfigureAwait(false); } else { // if page loaded from adminspage it will back to adminspage ap = new AdminsPage("", mv); mv.MenuPage.Content = ap; ap.LoadData().ConfigureAwait(false); Console.WriteLine("<<<<<<<<<<<<<<<<<<<< not From Profilr"); } }
public AdminProfile GetAdminProfile(long userId) { try { var objUserModel = new AdminProfile(); objUserModel = _schoolContext.UserProfile.Where(u => u.UserId == userId).Select(u => new Model.AdminProfile { UserId = u.UserId, FirstName = u.FirstName, LastName = u.LastName, Email = u.Email, ContactNumber = u.ContactNumber, }).FirstOrDefault(); return(objUserModel); } catch (System.Exception ex) { var x = ex; throw; } }
protected void Page_Load(object sender, EventArgs e) { string str; this.xmlDoc = new XmlDocument(); HttpContext current = HttpContext.Current; if (current != null) { str = current.Server.MapPath("~/Admin/Common/QuickLinks.xml"); } else { str = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Admin/Common/QuickLinks.xml"); } this.xmlDoc.Load(str); AdminProfileInfo adminProfile = AdminProfile.GetAdminProfile(PEContext.Current.Admin.AdminName); this.quickConfig = this.ConvertToCollection(adminProfile); this.RptQuickLinks.DataSource = this.xmlDoc.SelectNodes("/Links/Module"); this.RptQuickLinks.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { if (string.IsNullOrEmpty(base.Title)) { base.Title = "备忘录(自动保存)"; } if (!this.Page.IsPostBack) { if (base.Session["AdminNoteText"] != null) { this.TxtEditor.Text = base.Session["AdminNoteText"].ToString(); } else { AdminProfileInfo adminProfile = AdminProfile.GetAdminProfile(PEContext.Current.Admin.AdminName); if (!adminProfile.IsNull) { this.TxtEditor.Text = adminProfile.NoteText; } } } }
public async Task <AdminProfileErrorCodes> UpdateAsync(AdminProfile adminProfile) { using (var context = _contextFactory.CreateDataContext()) { var entity = await context.AdminProfiles.FindAsync(adminProfile.AdminId); if (entity == null) { return(AdminProfileErrorCodes.AdminProfileDoesNotExist); } _encryptionService.Decrypt(entity); entity.Update(adminProfile); _encryptionService.Encrypt(entity); await context.SaveChangesAsync(); } return(AdminProfileErrorCodes.None); }
public async Task <AdminProfileErrorCodes> InsertAsync(AdminProfile adminProfile) { using (var context = _contextFactory.CreateDataContext()) { var entity = await context.AdminProfiles.FindAsync(adminProfile.AdminId); if (entity != null) { return(AdminProfileErrorCodes.AdminProfileAlreadyExists); } entity = new AdminProfileEntity(adminProfile); entity = _encryptionService.Encrypt(entity); context.AdminProfiles.Add(entity); await context.SaveChangesAsync(); } return(AdminProfileErrorCodes.None); }
public ActionResult MyProfile() { // get logged in user var user = dobj.Users.Where(x => x.EmailID == User.Identity.Name).FirstOrDefault(); // get logged in user's profile var userprofile = dobj.AdminDetail.Where(x => x.AdminID == user.ID).FirstOrDefault(); // create adminprofile AdminProfile adminprofile = new AdminProfile(); if (userprofile != null) { adminprofile.FirstName = user.FirstName; adminprofile.LastName = user.LastName; adminprofile.Email = user.EmailID; adminprofile.AdminID = user.ID; adminprofile.CountryCode = userprofile.CountryCode; adminprofile.PhoneNumber = userprofile.PhoneNumber; if (userprofile.SecondaryEmail != null) { adminprofile.SecondaryEmail = userprofile.SecondaryEmail; } if (userprofile.ProfilePicture != null) { adminprofile.ProfilePictureUrl = userprofile.ProfilePicture; } adminprofile.CountryCodeList = dobj.Countries.Where(x => x.IsActive).OrderBy(x => x.CountryCode).Select(x => x.CountryCode).ToList(); } else { adminprofile.FirstName = user.FirstName; adminprofile.LastName = user.LastName; adminprofile.Email = user.EmailID; adminprofile.CountryCodeList = dobj.Countries.Where(x => x.IsActive).OrderBy(x => x.CountryCode).Select(x => x.CountryCode).ToList(); } return(View(adminprofile)); }
public AdminProfile UpdateAdminProfile(AdminProfile adminProfile) { try { var result = _schoolContext.UserProfile.Where(u => u.UserId == adminProfile.UserId).FirstOrDefault(); if (result != null) { result.FirstName = adminProfile.FirstName; result.LastName = adminProfile.LastName; result.ContactNumber = adminProfile.ContactNumber; _schoolContext.UserProfile.Add(result); _schoolContext.SaveChanges(); } return(adminProfile); } catch (System.Exception ex) { var x = ex; throw; } }
public async Task <DatabaseResponse> UpdateAdminProfile(int AdminUserID, AdminProfile adminuser) { try { SqlParameter[] parameters = { new SqlParameter("@AdminID", SqlDbType.Int), new SqlParameter("@Name", SqlDbType.NVarChar), new SqlParameter("@NewPassword", SqlDbType.NVarChar) }; parameters[0].Value = AdminUserID; parameters[1].Value = adminuser.Name; parameters[2].Value = new Sha2().Hash(adminuser.NewPassword); _DataHelper = new DataAccessHelper("Admin_UpdateProfile", parameters, _configuration); DataTable dt = new DataTable(); int result = await _DataHelper.RunAsync(dt); return(new DatabaseResponse { ResponseCode = result, Results = adminuser }); } catch (Exception ex) { LogInfo.Error(new ExceptionHelper().GetLogString(ex, ErrorLevel.Critical)); throw (ex); } finally { _DataHelper.Dispose(); } }
public CreateAccountModel() { Profile = new AdminProfile(); }
public EditProfileModel() { Profile = new AdminProfile(); }
public async Task <ActionResult <AdminProfile> > GetTokenAndProfile( [FromBody, Required] SessionIdModel sessionIdModel) { if (sessionIdModel == null || string.IsNullOrWhiteSpace(sessionIdModel.SessionId)) { return(BadRequest(ErrorModel.SessionIdError)); } bool isSuccess = _memoryCache.TryGetValue(sessionIdModel.SessionId, out CacheModel sessionInfo); if (isSuccess == false || sessionInfo == null) { return(BadRequest(ErrorModel.SessionIdError)); } if (sessionInfo.UserStartedAuthorization == false) { return(BadRequest(ErrorModel.AuthorizationAborted)); } isSuccess = _memoryCache.TryGetValue(sessionIdModel.SessionId, out sessionInfo); if (isSuccess && sessionInfo?.UserProfile == null) { int requestCounter = 0; while (requestCounter < 50) { isSuccess = _memoryCache.TryGetValue(sessionIdModel.SessionId, out sessionInfo); if (isSuccess && sessionInfo?.UserProfile != null) { break; } await Task.Delay(200); requestCounter++; } } if (sessionInfo?.UserProfile == null) { return(BadRequest(ErrorModel.AuthorizationError("Error occured during the authorization process. " + "Unable to receive user's profile for some reasons"))); } var admin = new AdminProfile(_memoryCache.Get <CacheModel>(sessionIdModel.SessionId).UserProfile); if (_backOfficeContext.Admins.FirstOrDefault(a => a.Name == admin.Id) == null) { await _backOfficeContext.Admins.AddAsync(new Admin() { Name = admin.Id }); await _backOfficeContext.SaveChangesAsync(); } var identity = _authService.GetIdentity(admin.Id); var jwt = _authService.GenerateToken(identity.Claims); var encodedJwt = new JwtSecurityTokenHandler().WriteToken(jwt); var refreshToken = _authService.GenerateRefreshToken(); _refreshTokenService.SaveRefreshToken(identity.Name, refreshToken); Response.Cookies.Append("X-Refresh-Token", refreshToken, new CookieOptions { HttpOnly = true, Secure = true, Expires = DateTime.UtcNow.AddDays(7), SameSite = SameSiteMode.None }); admin.Token = encodedJwt; return(new JsonResult(admin)); }