public SaveResult SendTestEmail(UserIdRequest request) { try { string link = "http://adventureworksmvc.synergos.hr/"; string message = "Hello,<br/><br/>\n" + $"This is test email sent from application {AppSettings.AppName} ({link}).<br/><br/>\n" + "Best regards<br/>"; UserViewModel user = UserProfileHelper.GetUser(request.Id); if (string.IsNullOrEmpty(user.Email)) { return new SaveResult { Status = "error", Message = "User doesn't have email address." } } ; EmailHelper.SendMail(AppSettings.AppName, user.Email, string.IsNullOrEmpty(user.FullName) ? user.Email : user.FullName, message); return(new SaveResult { Status = "success" }); } catch (Exception ex) { return(new SaveResult { Status = "error", Message = ex.Message }); } }
private static UserInfo MapToModel(User u) { var info = new UserInfo(); var profile = UserProfileHelper.GetUserProfile(u.LoginName); info.Id = u.Id; info.Upn = u.LoginName; var form = GetUserForm(u.LoginName); info.CurrentFormId = form == null ? 0 : form.Id; info.CurrentFormStatus = form == null ? "Not Available" : form.FormStatus; info.Groups = u.Groups.Select(x => x.Title).ToList(); info.IsReviewer = info.IsInGroup(SharePointHelper.ReviewerGroup); info.IsAdmin = info.IsInGroup(SharePointHelper.AdminGroup); info.DisplayName = profile.DisplayName; info.UserProfileUrl = profile.UserUrl; info.Email = profile.Email; info.PhoneNumber = profile.IsPropertyAvailable("UserProfileProperties") && profile.UserProfileProperties.ContainsKey("WorkPhone") ? profile.UserProfileProperties["WorkPhone"] : string.Empty; info.Branch = profile.IsPropertyAvailable("UserProfileProperties") && profile.UserProfileProperties.ContainsKey("Office") ? profile.UserProfileProperties["Office"] : string.Empty; return(info); }
protected void BtnUpdate_Click(object sender, EventArgs e) { string userid = User.Identity.GetUserId(); int UserProfileId = UserProfileHelper.GetUserprofileId(userid); Button btn = (Button)sender; ListViewItem item = (ListViewItem)btn.NamingContainer; TextBox Fname = (TextBox)item.FindControl("FirstNameLabel"); TextBox Lname = (TextBox)item.FindControl("LastnameLabel"); TextBox Email = (TextBox)item.FindControl("EmailLabel"); TextBox Phone = (TextBox)item.FindControl("PhoneLabel"); Label Picture = (Label)item.FindControl("ProfilrpicLabel"); FileUpload Pimage1 = (FileUpload)item.FindControl("FileUpload1"); UserProfile u = new UserProfile(); u.FirstName = Fname.Text; u.Lastname = Lname.Text; u.Email = Email.Text; u.Phone = Phone.Text; if (Pimage1.FileName != "") { u.Profilrpic = Pimage1.FileName; Pimage1.SaveAs(Server.MapPath("~/ProfilePicture/" + u.Profilrpic)); } else { u.Profilrpic = Picture.Text; } u.UserProfileId = UserProfileId; UserProfileHelper.UpdateProfileSetting(u); Response.Redirect("ProfileSetting"); }
public async Task <IActionResult> GetUserByEmail(string email) { if (string.IsNullOrEmpty(email)) { ModelState.AddModelError(nameof(email), "email cannot be empty"); return(BadRequest(ModelState)); } if (!(new EmailAddressAttribute().IsValid(email))) { ModelState.AddModelError(nameof(email), "email does not exist"); return(NotFound(ModelState)); } var emailText = email.Replace("'", "''"); var filter = $"otherMails/any(c:c eq '{emailText}')"; var profile = new UserProfileHelper(_userAccountService, _settings); var userProfile = await profile.GetUserProfileAsync(filter); if (userProfile == null) { return(NotFound()); } return(Ok(userProfile)); }
public async Task <IActionResult> OnPost(IFormFile avatar) { var imageByte = avatar; BinaryReader br = new BinaryReader(imageByte.OpenReadStream()); userProfile.AvatarOne = br.ReadBytes((int)imageByte.OpenReadStream().Length); userProfile.Username = token.username; userProfile.Firstname = Request.Form["firstname"]; userProfile.Lastname = Request.Form["lastname"]; userProfile.Email = Request.Form["email"]; userProfile.Cell = Request.Form["cell"]; userProfile.AddressOne = Request.Form["addressone"]; userProfile.AddressTwo = Request.Form["addresstwo"]; userProfile.Zip = Request.Form["zip"]; userProfile.NameOnCard = Request.Form["nameoncard"]; userProfile.CVV = Request.Form["cvv"]; userProfile.CardNumber = Request.Form["cardnumber"]; userProfile.ExpirationOnCard = DateTime.Parse(Request.Form["expdate"]); userProfile.PaymentType = Request.Form["paymenttype"]; var helper = new UserProfileHelper(Configuration, token); if (await helper.PostProfile(userProfile)) { return(RedirectToPage("/Profile")); } else { return(RedirectToPage("/Error")); } }
public async Task <IActionResult> GetUserByUserName(string userName) { if (string.IsNullOrEmpty(userName)) { ModelState.AddModelError(nameof(userName), "user principal name cannot be empty"); return(BadRequest(ModelState)); } var filterText = userName.Replace("'", "''"); var filter = $"userPrincipalName eq '{filterText}'"; var profile = new UserProfileHelper(_userAccountService, _settings); try { var userProfile = await profile.GetUserProfileAsync(filter); if (userProfile != null) { return(Ok(userProfile)); } ModelState.AddModelError(nameof(userName), "user principal name does not exist"); return(NotFound(ModelState)); } catch (UnauthorizedAccessException ex) { return(Unauthorized(ex.Message)); } }
public async Task <IActionResult> OnPost(IFormFile avatar) { var imageByte = avatar; BinaryReader br = new BinaryReader(imageByte.OpenReadStream()); userProfile.AvatarOne = br.ReadBytes((int)imageByte.OpenReadStream().Length); userProfile.Username = token.username; userProfile.Firstname = Request.Form["firstname"]; userProfile.Lastname = Request.Form["lastname"]; userProfile.Email = Request.Form["email"]; userProfile.Cell = Request.Form["cell"]; userProfile.AddressOne = Request.Form["addressone"]; userProfile.AddressTwo = Request.Form["addresstwo"]; userProfile.Zip = Request.Form["zip"]; var helper = new UserProfileHelper(Configuration, token); if (await helper.PostProfile(userProfile)) { return(RedirectToPage("/Profile")); } else { return(RedirectToPage("/Error")); } }
// GET: /Test/ListAllCustomer public ActionResult ListAllCustomer() { var tenantDb = new TenantRegistryEntities(); var appDb = new AppDBEntities(UserProfileHelper.ResolveUserDBConnectionString()); var customers = appDb.Customers.ToList(); return(View(customers)); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string userid = User.Identity.GetUserId(); int UserprofileId = UserProfileHelper.GetUserprofileId(userid); DataSet ds = CartHelper.ViewMyCart(UserprofileId); ListView1.DataSource = ds; ListView1.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { string userid = User.Identity.GetUserId(); if (!IsPostBack) { DataSet ds = UserProfileHelper.ViewMyprofileDetails(userid); ListView1.DataSource = ds; ListView1.DataBind(); } }
private void LoadUserProfile() { this.UserProfile = UserProfileHelper.LoadUserProfile(); if (!string.IsNullOrEmpty(this.UserProfile.LastPlayedFile)) { this.ResumeLastSrtFile = this.UserProfile.LastPlayedFile; this.ResumeLastSrtFileName = new FileInfo(this.ResumeLastSrtFile).Name; this.IsFilePlayChoiceVisible = true; this.IsResumeFile = true; } }
public static void SyncUserProfilesToEmployees() { var ldapUsers = UserProfileHelper.Query(); var info = "ldapUsers.Count: " + ldapUsers.Count.ToString(); DebugLog.Log("SyncUserProfilesToEmployees", "OGE450", "OOGC.Data.SharePoint.Employee", "SyncUserProfilesToEmployees", info, "Info", DateTime.Now); var knownEmployees = Employee.GetAll(); var prefix = ""; info = "knownEmployees.Count: " + knownEmployees.Count.ToString(); DebugLog.Log("SyncUserProfilesToEmployees", "OGE450", "OOGC.Data.SharePoint.Employee", "SyncUserProfilesToEmployees", info, "Info", DateTime.Now); prefix = "i:0e.t|adfs|"; var result = from ldap in ldapUsers join emp in knownEmployees on prefix + ldap.UPN.ToLower() equals emp.AccountName.ToLower() into emps from emp in emps.DefaultIfEmpty() where emp == null || ldap.Inactive != emp.Inactive select new Employee() { Id = emp == null ? 0 : emp.Id, AccountName = prefix + ldap.UPN, Title = ldap.DisplayName, Inactive = ldap.Inactive }; if (result != null) { var employees = result.ToList(); info = "employees.Count: " + employees.Count.ToString(); DebugLog.Log("SyncUserProfilesToEmployees", "OGE450", "OOGC.Data.SharePoint.Employee", "SyncUserProfilesToEmployees", info, "Info", DateTime.Now); foreach (Employee emp in employees) { if (emp.Inactive) { emp.Deactivate(); } if (emp.Id == 0) { emp.FilerType = Constants.FilerType.NOT_ASSIGNED; } emp.Save(); } } }
async Task <bool> LoginAsync(MobileServiceAuthenticationProvider provider) { if (!Plugin.Connectivity.CrossConnectivity.Current.IsConnected) { Acr.UserDialogs.UserDialogs.Instance.Alert("Ensure you have internet connection to login.", "No Connection", "OK"); return(false); } MobileServiceUser user = null; try { authentication.ClearCookies(); user = await authentication.LoginAsync(client, provider); if (user != null) { IsBusy = true; UserProfile = await UserProfileHelper.GetUserProfileAsync(client); } } catch (Exception ex) { Logger.Instance.Report(ex); } finally { IsBusy = false; } if (user == null || UserProfile == null) { Settings.LoginAccount = LoginAccount.None; Settings.UserFirstName = string.Empty; Settings.AuthToken = string.Empty; Settings.UserLastName = string.Empty; Logger.Instance.Track("LoginError"); Acr.UserDialogs.UserDialogs.Instance.Alert("Unable to login or create account.", "Login error", "OK"); return(false); } else { Init(); Logger.Instance.Track("LoginSuccess"); } return(true); }
public IActionResult Setup(UserProfileModel profile) { profile.ID = Guid.Parse(_userManager.GetUserId(User)); UserProfileHelper.AddOrUpdate(_database, profile, out var newProfile); if (newProfile) { _logger.Info($"New Profile Created: {profile.ID}, {profile.Name}"); } return(RedirectToAction("Index")); }
private static UserInfo MapToModel(User u) { var info = new UserInfo(); info.Id = u.Id; info.Upn = u.LoginName; OGEForm450 form = null; form = GetUserForm(u.LoginName); if (form != null) { info.CurrentFormId = form.Id; info.CurrentFormStatus = form.FormStatus; } else { info.CurrentFormId = 0; info.CurrentFormStatus = "Not Available"; } var profile = UserProfileHelper.GetUserProfile(u.LoginName); if (profile != null) { info.DisplayName = profile.IsPropertyAvailable("DisplayName") ? profile.DisplayName : u.LoginName; info.UserProfileUrl = profile.IsPropertyAvailable("UserUrl") ? profile.UserUrl : ""; info.Email = profile.IsPropertyAvailable("Email") ? profile.Email : ""; //info.Manager = (profile.IsPropertyAvailable("UserProfileProperties") && profile.UserProfileProperties.ContainsKey("Manager")) ? profile.UserProfileProperties["Manager"] : string.Empty; info.PhoneNumber = (profile.IsPropertyAvailable("UserProfileProperties") && profile.UserProfileProperties.ContainsKey("WorkPhone")) ? profile.UserProfileProperties["WorkPhone"] : string.Empty; info.Branch = (profile.IsPropertyAvailable("UserProfileProperties") && profile.UserProfileProperties.ContainsKey("Office")) ? profile.UserProfileProperties["Office"] : string.Empty; } try { info.Groups = u.Groups.Select(x => x.Title).ToList(); info.IsReviewer = info.IsInGroup(SharePointHelper.ReviewerGroup); info.IsAdmin = info.IsInGroup(SharePointHelper.AdminGroup); info.IsRestrictedAdmin = info.IsInGroup(SharePointHelper.RestrictedAdmin); } catch (Exception ex) { // ignore } info.InMaintMode = Settings.IN_MAINTENANCE_MODE; return(info); }
// GET: /Test/ListCustomer public ActionResult ListCustomer() { var tenantDb = new TenantRegistryEntities(); var appDb = new AppDBEntities(UserProfileHelper.ResolveUserDBConnectionString()); // Register Username and TenantId to memory UserProfileHelper.RegisterUserTenant(); // get tenant id from memory variable var tid = UserProfileHelper.UserTenantLookup[User.Identity.Name].ToString(); var customers = appDb.Customers.Where(c => c.TenantId == tid); return(View(customers)); }
public async Task <IActionResult> GetUserByAdUserId(string userId) { var filterText = userId.Replace("'", "''"); var filter = $"objectId eq '{filterText}'"; var profile = new UserProfileHelper(_userAccountService, _settings); var userProfile = await profile.GetUserProfileAsync(filter); if (userProfile == null) { ModelState.AddModelError(nameof(userId), "user does not exist"); return(NotFound(ModelState)); } return(Ok(userProfile)); }
protected void BtnCart_Click(object sender, EventArgs e) { string userid = User.Identity.GetUserId(); Button btn = (Button)sender; ListViewItem item = (ListViewItem)btn.NamingContainer; Label id = (Label)item.FindControl("ProductIdLabel"); TextBox quantity = (TextBox)item.FindControl("TxtQuantity"); Cart c = new Cart(); c.ProductId = int.Parse(id.Text); c.Quantity = int.Parse(quantity.Text); c.UserProfileId = UserProfileHelper.GetUserprofileId(userid); CartHelper.InsertCart(c); }
public IActionResult Index() { if (!_signInManager.IsSignedIn(User)) { return(RedirectToAction("Index", "Home")); } var userProfile = UserProfileHelper.GetUserProfile(_database, _userManager.GetUserId(User)); if (userProfile == null) { return(RedirectToAction("Setup")); } return(View()); }
public static void GetEmployeeUserProfileInfo(Employee emp) { var userProfile = UserProfileHelper.GetUserProfile(emp.AccountName); if (userProfile != null) { emp.Title = userProfile.IsPropertyAvailable("DisplayName") ? userProfile.DisplayName : string.Empty; emp.DisplayName = userProfile.IsPropertyAvailable("DisplayName") ? userProfile.DisplayName : string.Empty; emp.EmailAddress = userProfile.IsPropertyAvailable("Email") ? userProfile.Email : string.Empty; emp.Position = userProfile.IsPropertyAvailable("Title") ? userProfile.Title : string.Empty; emp.WorkPhone = userProfile.IsPropertyAvailable("UserProfileProperties") && userProfile.UserProfileProperties.ContainsKey("WorkPhone") ? userProfile.UserProfileProperties["WorkPhone"] : string.Empty; emp.Agency = userProfile.IsPropertyAvailable("UserProfileProperties") && userProfile.UserProfileProperties.ContainsKey("Department") ? userProfile.UserProfileProperties["Department"] : string.Empty; emp.Branch = userProfile.IsPropertyAvailable("UserProfileProperties") && userProfile.UserProfileProperties.ContainsKey("Office") ? userProfile.UserProfileProperties["Office"] : string.Empty; emp.ProfileUrl = userProfile.IsPropertyAvailable("UserUrl") ? userProfile.UserUrl : string.Empty; emp.PictureUrl = userProfile.IsPropertyAvailable("PictureUrl") ? userProfile.PictureUrl : string.Empty; } }
private bool CheckIfConfiguredShowErrorIfNot() { Guid shoppingCartId = this.GetShoppingCartId(); if (shoppingCartId == Guid.Empty) { return(ShowErrorMessageAndHidePanels("You cannot checkout without having anything in the cart")); } else if (CartHelper.GetCartOrder(this.OrdersManager, shoppingCartId).Details.Count == 0) { return(ShowErrorMessageAndHidePanels("You cannot checkout with no items in the cart")); } else if (UserProfileHelper.GetCurrentUserId() == Guid.Empty) { return(ShowErrorMessageAndHidePanels("You have to login to use checkout")); } return(true); }
protected void BtnSave_Click(object sender, EventArgs e) { UserProfile u = new UserProfile(); u.FirstName = TxtFname.Text; u.Lastname = TxtLname.Text; u.Email = TxtEmail.Text; u.Phone = TxtPhone.Text; u.HouseName = TxtHouseName.Text; u.Street = TxtStreet.Text; u.City = TxtCity.Text; u.State = TxtState.Text; u.Country = TxtCountry.Text; u.Zip = int.Parse(TxtZip.Text); u.Profilrpic = FileUpload1.FileName; FileUpload1.SaveAs(Server.MapPath("~/ProfilePicture/" + FileUpload1.FileName)); u.UserId = User.Identity.GetUserId(); UserProfileHelper.InsertUserProfile(u); }
public async Task <IActionResult> OnGet() { var helper = new UserProfileHelper(this.Configuration, this.token); if (this.userProfile.Firstname == null) { var response = await helper.GetProfile(token.username); if (response != null) { userProfile.Username = response.Username; userProfile.AvatarOne = response.AvatarOne; userProfile.Firstname = response.Firstname; userProfile.Lastname = response.Lastname; userProfile.AddressOne = response.AddressOne; userProfile.AddressTwo = response.AddressTwo; userProfile.Email = response.Email; userProfile.Cell = response.Cell; userProfile.Country = response.Country; userProfile.Zip = response.Zip; userProfile.NameOnCard = response.NameOnCard; userProfile.PaymentType = response.PaymentType; userProfile.ExpirationOnCard = response.ExpirationOnCard; userProfile.CardNumber = response.CardNumber; userProfile.CVV = response.CVV; } if (response != null) { return(RedirectToPage("ProfileView")); } else { return(RedirectToPage("ProfileAdd")); } } else { return(RedirectToPage("ProfileView")); } }
public override void MapToList(ListItem dest) { var userProfile = UserProfileHelper.GetUserProfile(this.Employee); if (Id == 0) { dest["Employee"] = SharePointHelper.GetFieldUser(this.Employee); } base.MapToList(dest); dest["EmployeesName"] = userProfile != null ? userProfile.DisplayName : ""; dest["DateAndTime"] = SharePointHelper.ToDateTimeNullIfMin(DateAndTime); dest["Location"] = Location; dest["EthicsOfficial"] = EthicsOfficial; dest["Year"] = Year; dest["TrainingType"] = TrainingType; dest["Division"] = Division; }
public IActionResult Posts(string userId) { var currentUserId = this.userManager.GetUserId(this.User); if (userId == null) { userId = currentUserId; } var viewModel = this.profilesService.GetUserInfoWithPosts(userId); var isProfileOwner = UserProfileHelper.CheckIfProfileOwner(userId, currentUserId); viewModel.IsProfileOwner = isProfileOwner; var isFollowed = this.followsService.IsFollowed(userId, currentUserId); viewModel.IsFollowed = isFollowed; return(this.View(viewModel)); }
// // GET: /Profile/ public ActionResult Index() { // Register Username and TenantId to memory UserProfileHelper.RegisterUserTenant(); var profile = db.UserProfiles.Include("Tenant").SingleOrDefault(u => u.Username == User.Identity.Name); // get tenant id from memory variable var tid = UserProfileHelper.UserTenantLookup[User.Identity.Name].ToString(); var customers = appDb.Customers.Where(c => c.TenantId == tid).ToList(); var models = new ProfileCustomerViewModel { UserProfile = profile, Customers = customers }; return(View(models)); }
public void Setup() { _accountService = new Mock <IUserAccountService>(); _settings = new Settings { IsLive = true, ReformEmail = Domain.Replace("@", ""), AdGroup = new AdGroup { Administrator = "Admin", CaseType = "CT", External = "Ext", Judge = "JudgeGroup", ProfessionalUser = "******", JudgesTestGroup = "TA", JudicialOfficeHolder = "JOH" } }; _helper = new UserProfileHelper(_accountService.Object, _settings); }
private void chkRemember_CheckedChanged(object sender, EventArgs e) { if (chkRemember.Checked) // Record username in C:\Temp\remember.json (should really encrypt it). { UserProfileHelper.userProfile.Remember = UserName; UserProfileHelper.SaveUserProfile(); txt.Text = AppConfigHelper.Password(UserName); } else // Unchecked { try { UserProfileHelper.userProfile.Remember = string.Empty; UserProfileHelper.SaveUserProfile(); txt.Text = string.Empty; } catch (Exception) { } } }
public static IEnumerable <Employee> GetEmployeesFromLDAP(List <Employee> employees) { var ldapUsers = UserProfileHelper.Query(); var prefix = "i:0e.t|adfs|"; var result = from ldap in ldapUsers join emp in employees on prefix + ldap.UPN.ToLower() equals emp.AccountName.ToLower() into emps from emp in emps.DefaultIfEmpty() select new Employee() { Id = emp == null ? 0 : emp.Id, AccountName = prefix + ldap.UPN, Title = ldap.DisplayName, Inactive = ldap.Inactive, EmailAddress = ldap.Email }; return(result); }
public async Task <IActionResult> OnPost(IFormFile avatar) { if (avatar != null) { BinaryReader br = new BinaryReader(avatar.OpenReadStream()); userProfile.AvatarOne = br.ReadBytes((int)avatar.OpenReadStream().Length) ?? userProfile.AvatarOne; } userProfile.Username = token.username ?? userProfile.Username; userProfile.Firstname = (Request.Form["firstname"]).ToString() ?? userProfile.Firstname; userProfile.Lastname = (Request.Form["lastname"]).ToString() ?? userProfile.Lastname; userProfile.Email = (Request.Form["email"]).ToString() ?? userProfile.Email; userProfile.Cell = (Request.Form["cell"]).ToString() ?? userProfile.Cell; userProfile.AddressOne = (Request.Form["addressone"]).ToString() ?? userProfile.AddressOne; userProfile.AddressTwo = (Request.Form["addresstwo"]).ToString() ?? userProfile.AddressTwo; userProfile.Zip = (Request.Form["zip"]).ToString() ?? userProfile.Zip; userProfile.NameOnCard = (Request.Form["nameoncard"]).ToString() ?? userProfile.NameOnCard; userProfile.CVV = (Request.Form["cvv"]).ToString() ?? userProfile.CVV; userProfile.CardNumber = (Request.Form["cardnumber"]).ToString() ?? userProfile.CardNumber; userProfile.ExpirationOnCard = DateTime.Parse(Request.Form["expdate"]); userProfile.PaymentType = Request.Form["paymenttype"]; var helper = new UserProfileHelper(configuration, token); if (await helper.EditProfile(userProfile)) { return(RedirectToPage("/Profile")); } else { return(RedirectToPage("/Error")); } }
public ApplicationManager(ICapabilities capabilities, string baseUrl) { Pages = new PageManager(capabilities, baseUrl); LoginHelper = new LoginHelper(this); UserProfileHelper = new UserProfileHelper(this); }