private void profileUpdateClick(object obj) { this.profileUpdate.IsEnabled = false; Mouse.OverrideCursor = Cursors.Wait; try { Userinformation userInfo = obj as Userinformation; this.ServiceConnectionChecker(); if (ServerConnection.serviceFromServer.AccountUpdate(counter.customerDetail.Username, userInfo)) { counter.customerDetail.Photo = userInfo.UserImage; Mouse.OverrideCursor = null; DXMessageBox.Show(CVsVariables.ERROR_MESSAGES[0, 6], CVsVariables.SOTWARE_NAME, MessageBoxButton.OK, MessageBoxImage.Information); } else { Mouse.OverrideCursor = null; DXMessageBox.Show(CVsVariables.ERROR_MESSAGES[0, 7], CVsVariables.SOTWARE_NAME, MessageBoxButton.OK, MessageBoxImage.Information); } } catch (Exception error) { Mouse.OverrideCursor = null; DXMessageBox.Show(error.Message, CVsVariables.SOTWARE_NAME, MessageBoxButton.OK, MessageBoxImage.Error); } finally { this.profileUpdate.IsEnabled = true; Mouse.OverrideCursor = null; } }
public ActionResult Index() { var subcontractors = db.SubContractors .Include(s => s.Administrator) .Where(s => s.Active); var id = User.Identity.GetUserId(); List <Userinformation> userlist = new List <Userinformation>(); var role = db.Roles.Include(x => x.Users).ToList(); var organization = ""; var usr = db.Users.Find(id); organization = db.SubContractors.Find(usr.SubcontractorId).OrgName; var usersub = db.SubContractors.Find(usr.SubcontractorId); if (usersub != null) { foreach (var users in db.Users.Where(s => s.SubcontractorId == usersub.SubcontractorId)) { var obj = new Userinformation { Id = new Guid(users.Id), Firstname = users.FirstName, Lastname = users.LastName, Email = users.Email, }; userlist.Add(obj); } } var affiliatesRegion = usersub.AffiliateRegion; var region = usersub.Region; ViewBag.Orgname = organization; ViewBag.Users = userlist; ViewBag.AR = affiliatesRegion; ViewBag.Region = region.GetDisplayName(); return(View(subcontractors.OrderBy(a => a.OrgName))); }
private void profileImagebrowseClick(object obj) { this.profileImageBrowse.IsEnabled = false; Mouse.OverrideCursor = Cursors.Wait; try { Userinformation userInfo = obj as Userinformation; userInfo.UserImage = imageOpenDialogBox(); } catch (Exception error) { Mouse.OverrideCursor = null; DXMessageBox.Show(error.Message, CVsVariables.SOTWARE_NAME, MessageBoxButton.OK, MessageBoxImage.Error); } finally { this.profileImageBrowse.IsEnabled = true; Mouse.OverrideCursor = null; } }
public bool AccountUpdate(string username, Userinformation updateinfo) { try { using (Cafeteria_Vernier_dbEntities cvDatabase = new Cafeteria_Vernier_dbEntities()) { var customerInfo = cvDatabase.CustomerInformations.First(x => x.UserID.Equals(username)); customerInfo.Address = updateinfo.Address; customerInfo.Email = updateinfo.Email; customerInfo.Logo = updateinfo.UserImage; customerInfo.NationalID = updateinfo.NationalID; customerInfo.Phone = updateinfo.Phone; cvDatabase.SaveChanges(); return(true); } } catch { throw new FaultException(ServiceVariables.ERROR_MESSAGES[0, 2]); } }
public ActionResult Edit(Userinformation user) { var client = db.Users.Find(user.Id.ToString()); var clientrole = client.Roles.FirstOrDefault().RoleId; var oldrolename = db.Roles.SingleOrDefault(r => r.Id == clientrole).Name; var org = Request["SubcontractorId"]; //updating database if (ModelState.IsValid) { var updateduser = db.Users.Single(s => s.Id == user.Id.ToString()); updateduser.SubcontractorId = new Guid(org); updateduser.FirstName = user.Firstname; updateduser.LastName = user.Lastname; updateduser.Email = user.Email; updateduser.UserName = user.Email; PasswordHasher password = new PasswordHasher(); var passwordhash = password.HashPassword(user.Password); updateduser.PasswordHash = passwordhash; if (oldrolename != db.Roles.SingleOrDefault(r => r.Id == user.Role).Name) { UserManager.RemoveFromRole(user.Id.ToString(), oldrolename); UserManager.AddToRole(user.Id.ToString(), db.Roles.SingleOrDefault(r => r.Id == user.Role).Name); } db.Entry(updateduser).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("IndexforRegisteredUsers")); } client = db.Users.Find(user.Id); clientrole = client.Roles.FirstOrDefault().RoleId; ViewBag.SubcontractorId = new SelectList(db.SubContractors.ToList(), "SubcontractorId", "OrgName", user.Organization); ViewBag.Role = new SelectList(db.Roles.ToList(), "Id", "Name", clientrole); return(View("Register", user)); }
public async Task <Userinformation> GetUserData() { UserInfo = await _userClient.GetData(); return(UserInfo); }
public ActionResult IndexforRegisteredUsers(string searchString, string currentFilter, int?page, int?pgSize) { ViewBag.Subcontractor = new SelectList(db.SubContractors.OrderBy(a => a.OrgName), "OrgName", "OrgName"); List <Userinformation> modelLst = new List <Userinformation>(); var role = db.Roles.Include(x => x.Users).ToList(); foreach (var r in role) { foreach (var u in r.Users) { var usr = db.Users.Find(u.UserId); var usersub = db.SubContractors.Find(usr.SubcontractorId).OrgName; if (usersub == null) { usersub = ""; } // looking for the searchstring if (searchString != null) { page = 1; } else { currentFilter = searchString; } ViewBag.CurrentFilter = searchString; var obj = new Userinformation { Id = new Guid(usr.Id), Firstname = usr.FirstName, Lastname = usr.LastName, Email = usr.Email, Role = r.Name, Organization = usersub }; modelLst.Add(obj); } } if (!String.IsNullOrEmpty(searchString)) { foreach (var items in modelLst.ToList()) { if (items.Organization != searchString) { modelLst.Remove(items); } } } int pageNumber = (page ?? 1); int defaSize = (pgSize ?? 15); ViewBag.psize = defaSize; ViewBag.PageSize = new List <SelectListItem>() { new SelectListItem() { Value = "10", Text = "10" }, new SelectListItem() { Value = "20", Text = "20" }, new SelectListItem() { Value = "30", Text = "30" }, new SelectListItem() { Value = "40", Text = "40" }, }; return(View(modelLst.OrderBy(s => s.Organization).ToPagedList(pageNumber, defaSize))); }