public ActionResult NewAccount(RegisterViewModel model) { Role role = new Role(model.Role); Account account = new Account(model.Username, model.Password, role); List <Beneficiary> list = new List <Beneficiary>(); foreach (var selected in model.Checkboxes) { if (selected.Checked) { list.Add(new Beneficiary(selected.Id, selected.Name)); } } AccountProfile profile = new AccountProfile(model.Name, list); AccountComplete complete = new AccountComplete(account, profile); var client = new RestClient("http://localhost:4000/api/AccountsCreate"); var request = new RestRequest(Method.POST); request.AddJsonBody(complete); var response = client.Execute <Account>(request); if (response.StatusCode == System.Net.HttpStatusCode.OK) { return(RedirectToAction("ViewAccountList", "Accounts")); } else if (response.StatusCode == System.Net.HttpStatusCode.BadRequest) { return(HttpNotFound()); } return(HttpNotFound()); }
public async Task <AccountProfile> DoLogin(AccountProfile profile) { string login = await profile.Client.GetStringAsync("https://ddownload.com/login.html"); Regex reg = new Regex("name=\"token\" value=\"([a-z0-9]*)\">"); Match m = reg.Match(login); Dictionary <string, string> paras = new Dictionary <string, string>(); paras.Add("op", "login"); paras.Add("rand", ""); paras.Add("redirect", "https://ddownload.com/"); paras.Add("token", m.Groups[0].Value); paras.Add("user", profile.Model.Username); paras.Add("pass", profile.Model.Password); try { HttpResponseMessage resp = await profile.Client.PostAsync("https://ddownload.com/", new FormUrlEncodedContent(paras)); } catch (Exception ex) { Console.WriteLine("Fehler beim einloggen bei ddownloader"); Console.WriteLine(ex.Message); } return(profile); }
private void AccountSelectionChanged() { try { ClearAccountDetailsDisplay(); if (_formState == FormStates.Loading) { return; } if (null == cboAccounts.SelectedItem) { return; } var selectedAccount = (AccountType)cboAccounts.SelectedItem; _selectedIdentity = AccountProfileHelper.GetTAccountInfo(selectedAccount); if (null != _selectedIdentity) { ViewAccount(_selectedIdentity); } } catch (Exception ex) { ExceptionHandler(ex); } }
public ActionResult ViewProfile() { var userIdCurrent = User.Identity.GetUserId(); var usersView = _context.Users.SingleOrDefault(u => u.Id == userIdCurrent); if (User.IsInRole("trainer")) { var TrainersView = _context.Trainers.SingleOrDefault(t => t.Id == usersView.Id); /* var courseTrainer = _context.Courses.SingleOrDefault(c => c.Id == trainerInWeb.CourseId);*/ var trainerInf = new AccountProfile() { UsersView = usersView, TrainersView = TrainersView }; return(View(trainerInf)); } if (User.IsInRole("trainee")) { var traineeInWeb = _context.Trainees.SingleOrDefault(t => t.Id == usersView.Id); var traineeInfor = new AccountProfile() { UsersView = usersView, TraineesView = traineeInWeb }; return(View(traineeInfor)); } var userInfor = new AccountProfile() { UsersView = usersView }; return(View(userInfor)); }
public async Task SaveProfile(AccountProfile model) { Data.Account account = await _store.LoadByGuid(model.GlobalId); if (account != null) { if (model.Name.HasValue()) { UpdateProperty(account, ClaimTypes.Name, model.Name); } UpdateProperty(account, ClaimTypes.Biography, model.Biography); UpdateProperty(account, ClaimTypes.Org, model.Org); UpdateProperty(account, ClaimTypes.Unit, model.Unit); string logo = Path.GetFileName(model.OrgLogo).Before('?'); if (logo == _options.Profile.DefaultLogo) { logo = ""; } UpdateProperty(account, ClaimTypes.OrgLogo, logo); logo = Path.GetFileName(model.UnitLogo).Before('?'); if (logo == _options.Profile.DefaultLogo) { logo = ""; } UpdateProperty(account, ClaimTypes.UnitLogo, logo); account.UpdatedAt = DateTime.UtcNow; await _store.Update(account); } }
public ActionResult ViewCourses() { var userIdCurrent = User.Identity.GetUserId(); var usersView = _context.Users.SingleOrDefault(u => u.Id == userIdCurrent); if (User.IsInRole("trainer")) { var trainersView = _context.Trainers.SingleOrDefault(t => t.Id == usersView.Id); var trainerCourse = _context.Courses.SingleOrDefault(c => c.Id == trainersView.CourseId); var courses = _context.Courses.Include(c => c.Category).ToList(); var trainerInfor = new AccountProfile() { UsersView = usersView, TrainersView = trainersView }; return(View(trainerCourse)); } else if (User.IsInRole("trainee")) { var traineeView = _context.Trainees.SingleOrDefault(t => t.Id == usersView.Id); var traineeCourse = _context.Courses.SingleOrDefault(c => c.Id == traineeView.CourseId); var courses = _context.Courses.Include(c => c.Category).ToList(); var traineeInfor = new AccountProfile() { UsersView = usersView, TraineesView = traineeView }; return(View(traineeCourse)); } return(HttpNotFound()); }
public async Task <Result <AuthorizedUser> > SignUp(string email, string username, string password) { await Task.Delay(1000); if (users.ContainsKey(username)) { return(new ErrorResult <AuthorizedUser>(new Error() { Code = Error.CodeUserExists, Message = LocalizedStrings.UserExists })); } lastId += 1; var newUser = new AccountProfile() { Id = lastId, Name = username, Email = email, Balance = 500 }; currentUserToken = email + password; currentUsername = username; users.Add(username, newUser); passwords.Add(email, password); return(new SuccessResult <AuthorizedUser>(new AuthorizedUser() { Token = currentUserToken })); }
public Employee Registration(Employee employee) { using (var db = new DataBaseContext()) { if (db.Accounts.FirstOrDefault(p => p.Login == employee.Login) == null) { var newAccount = new Account { Login = employee.Login, Password = employee.Password }; var newAccountProfile = new AccountProfile { FirstName = employee.FirstName, LastName = employee.LastName, Department = employee.Department }; db.Accounts.Add(newAccount); db.AccountProfiles.Add(newAccountProfile); db.SaveChanges(); int id = db.Accounts.FirstOrDefault(p => p.Login == employee.Login).EmployeeId; employee.Id = id; return(employee); } else { return(null); } } }
public Account(AccountProfile profile, AccountTokens tokens) { Profile = profile; Tokens = tokens; Settings = new AccountSettings(); VolatileData = new AccountVolatileData(); }
public ActionResult Order() { if (Session[UserIDKey] == null) { return(RedirectToAction("Login", "Users")); } AccountProfile accountProfile = new AccountProfile(); accountProfile.User = ModelContext.Users .Where(u => u.UserId == UserIdSession).SingleOrDefault(); accountProfile.Orders = ModelContext.Orders.Where(o => o.UserId == UserIdSession); accountProfile.Products = (from p in ModelContext.Products join o in ModelContext.Orders on p.ProductId equals o.ProductId select p); accountProfile.ProductImage = (from p in ModelContext.ProductImages join o in ModelContext.Orders on p.ProductId equals o.ProductId where p.IsDefaultImage == true select p); return(View(accountProfile)); }
public Account(Account account) { // Copy constructor excludes VolatileData (for storage) Profile = new AccountProfile(account.Profile); Tokens = new AccountTokens(account.Tokens); Settings = new AccountSettings(account.Settings); }
public static List <Order> GetMyOrders(this AccountProfile profile, OrderType orderType) { string json = RestHelper.Get($"profile/{MarketManager.Instance.Account.InGameName}/orders", requireAuth: true).Content.Replace("\\", "/"); var orderConfig = ProfileOrders_QuickType.FromJson(json); return((orderType == OrderType.Buy) ? orderConfig.Payload.BuyOrders : orderConfig.Payload.SellOrders); }
//TODO check token public async Task <AccountProfile> GetAccountProfile() //TODO change to profile object { //Gonna need to split these up (for every case of this), as we might be trying to access account info with a client cred (non-user) if (!await IsAuthenticationToken() || IsTokenExpired()) { //TODO implement getting/refreshing auth token } string path = "profile/user/wow"; AuthenticationHeaderValue authHeader = new AuthenticationHeaderValue("Bearer", token.access_token); List <KeyValuePair <string, string> > query = new List <KeyValuePair <string, string> >(); query.Add(new KeyValuePair <string, string>("region", "eu")); query.Add(new KeyValuePair <string, string>("namespace", "profile-eu")); query.Add(new KeyValuePair <string, string>("locale", "en_GB")); try { string response = await SendGet(false, path, query, authHeader); AccountProfile accountProfile = JsonConvert.DeserializeObject <AccountProfile>(response); return(accountProfile); //TODO implement profile object } catch (Exception e) { Console.WriteLine(e.Message); } return(null); //TODO implement profile object }
public void Add(Account account, AccountProfile profile) { //added if (account.UserName.ToLower() != SUPER) { Repository.Add(account, profile); } }
public async Task <int> DeleteAsync(int id) { AccountProfile model = await ReadByIdAsync(id); EntityExtension.FlagForDelete(model, IdentityService.Username, UserAgent, true); DbSet.Update(model); return(await DbContext.SaveChangesAsync()); }
public void AccountProfile() { mockXboxApiRestClient.Setup(x => x.AccountProfile()) .Returns(readTestResponse("AccountProfile/Success.json")); AccountProfile result = xboxAPI.AccountProfile().GetAwaiter().GetResult(); Assert.AreEqual(Xuid, result.userXuid); }
public AccountProfileController() { View = new AccountProfile(); client.BaseAddress = new Uri("https://localhost:44326/"); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add( new MediaTypeWithQualityHeaderValue("application/json")); InitControllerAsync(); }
public async Task <AccountModel> GetAccountInfo(AccountProfile profile) { string profileStr = ""; profileStr = await profile.Client.GetStringAsync("https://www.share-online.biz/user/profile"); if (!profileStr.Contains("willkommen im Benutzerbereich")) { profile.Model.IsPremium = false; profile.Model.TrafficLeft = 0; profile.Model.TrafficLeftWeek = 0; return(profile.Model); } if (!profileStr.Contains("Premium </p>")) { profile.Model.IsPremium = false; profile.Model.TrafficLeft = 0; profile.Model.TrafficLeftWeek = 0; return(profile.Model); } Regex reg = new Regex("Ihr Account-Typ:\n <\\/p>\n <p class=\"p_r\">\n(.*)<\\/p>"); string type = reg.Match(profileStr).Groups[1].Value.Trim(); profile.Model.IsPremium = type == "Premium" || type == "Penalty-Premium"; reg = new Regex("Aktuelles Guthaben <span class=\"sm\">\\(\\*\\*\\*\\)<\\/span>:\n <\\/p>\n <p class=\"p_r\">\n(.*)€"); float guthaben = float.Parse(reg.Match(profileStr).Groups[1].Value.Trim().Replace('.', ',')); profile.Model.Credit = guthaben; if (profile.Model.IsPremium) { reg = new Regex("Account gültig bis:\n <\\/p>\n <p class=\"p_r\">\n <span class='green'>(.*)<\\/span>"); string validdate = reg.Match(profileStr).Groups[1].Value.Trim(); profile.Model.ValidTill = DateTime.Parse(validdate); reg = new Regex("1 Tag: <img src='(.*)' alt='' width='16' height='16' title='([0-9]*)% verfügbar \\((.*) GiB\\)"); float traffic1 = float.Parse(reg.Match(profileStr).Groups[3].Value.Trim().Replace('.', ',')); reg = new Regex("7 Tage: <img src='(.*)' alt='' width='16' height='16' title='([0-9]*)% verfügbar \\((.*) GiB\\)"); float traffic7 = float.Parse(reg.Match(profileStr).Groups[3].Value.Trim().Replace('.', ',')); profile.Model.TrafficLeft = traffic1; profile.Model.TrafficLeftWeek = traffic7; } else { profile.Model.TrafficLeft = 0; profile.Model.TrafficLeftWeek = 0; } return(profile.Model); }
private void ClearAccountDetailsDisplay() { txtLogin.Clear(); txtPassword.Clear(); txtToken.Clear(); txtUrl.Clear(); txtOwner.Clear(); _selectedIdentity = null; }
public async Task <IActionResult> Put([FromBody] AccountProfile model) { if (!User.IsPrivilegedOrSelf(model.GlobalId)) { return(new ForbidResult()); } await _svc.SaveProfile(model); return(Ok()); }
public void Create(Account account, AccountProfile profile) { if (account.UserName.ToLower() != "super") { Service.Create(account, profile); } else { throw new InvalidUserException(nameof(account.UserName)); } }
public void FillProperties() { var profile = AccountProfile.GetProfileOfUser(this.aspnet_User.UserName); // the matched user FullName = profile.FullName; Grade = profile.Grade; // What sex is the current user? bool selectedSex = false; // male if (AccountProfile.CurrentUser.Sex == 2) { selectedSex = true; // female } // All school for whatever gender you are var allSchoolYourGender = this.aspnet_User.Matches1.Where(m => m.MatchedSex == selectedSex).OrderByDescending(m => m.CompatibilityIndex); // get their list // Figure out your position var result = allSchoolYourGender .Select((x, i) => new { Item = x, Index = i }) .Where(itemWithIndex => itemWithIndex.Item.MatchedUser == Current.UserID.Value) .FirstOrDefault(); int index = -1; if (result != null) { index = result.Index + 1; // index is zero-based, but we want to present list as starting with index 1. } PositionOnTheirListAllSchool = index; if (!this.AreSameGrade) { PositionOnTheirListYourGrade = -1; } else { // Your grade for whatever gender you are var yourGradeYourGender = this.aspnet_User.Matches1.Where(m => m.MatchedSex == selectedSex && m.AreSameGrade == true).OrderByDescending(m => m.CompatibilityIndex); // Figure out your position var resultG = allSchoolYourGender .Select((x, i) => new { Item = x, Index = i }) .Where(itemWithIndex => itemWithIndex.Item.MatchedUser == Current.UserID.Value) .FirstOrDefault(); int indexG = -1; if (resultG != null) { indexG = resultG.Index + 1; // index is zero-based, but we want to present list as starting with index 1. } PositionOnTheirListYourGrade = indexG; } }
private void ViewAccount(AccountProfile account) { try { SetFormState(FormStates.Viewing); switch (account.Account) { case AccountType.GitHub: { pnlLogin.Visible = true; pnlPassword.Visible = false; pnlToken.Visible = true; pnlOwner.Visible = true; pnlUrl.Visible = false; break; } case AccountType.JIRA: { pnlLogin.Visible = true; pnlPassword.Visible = true; pnlToken.Visible = false; pnlOwner.Visible = false; pnlUrl.Visible = true; break; } case AccountType.TeamCity: { pnlLogin.Visible = true; pnlPassword.Visible = true; pnlToken.Visible = false; pnlOwner.Visible = false; pnlUrl.Visible = false; break; } } txtLogin.Text = account.Login; txtPassword.Text = account.Password; txtToken.Text = account.Token; txtOwner.Text = account.Owner; txtUrl.Text = account.URL; } catch (Exception ex) { ExceptionHandler(ex); } }
public virtual ActionResult ShowSuspensionStatus() { var u = Membership.GetUser(); var db = Current.DB; if (!(AccountProfile.GetProfileOfUser(u.UserName).ReinstateDate < DateTime.Now)) { var suspension = db.UserSuspensions.Where(s => s.UserID == (Guid)u.ProviderUserKey).OrderByDescending(k => k.ReinstateDate).Take(1).ToList()[0]; return(View(suspension)); } return(RedirectToAction("Index", "Home")); }
public void UpdateUser(string userId, string firstName, string lastName, string email, string role, string roleEntityValue, string agencyManager = "") { if (string.IsNullOrEmpty(firstName) || string.IsNullOrEmpty(lastName) || string.IsNullOrEmpty(email) || string.IsNullOrEmpty(role) || (role == "AgencyCollector" && string.IsNullOrEmpty(agencyManager.Trim()))) { throw new Exception("Required fields are not passed"); } string userName = firstName.ToLower() + "." + lastName.ToLower(); AccountProfile profile; try { if (!string.IsNullOrEmpty(userId)) { profile = new AccountProfile(UserEntitiesDataFactory.GetUser(Guid.Parse(userId)).UserName); UserEntitiesDataFactory.UpdateUser(userId, email); UserEntitiesDataFactory.UpdateRole(userId, role); } else { if (UserEntitiesDataFactory.IsUserExits(userName)) { userName = UserEntitiesDataFactory.GetUsername(userName); } userId = UserEntitiesDataFactory.CreateUserWithRoles(userName, email, role).ToString(); profile = new AccountProfile(userName); } profile.FirstName = firstName; profile.LastName = lastName; if (!string.IsNullOrEmpty(roleEntityValue)) { profile.RoleEntityValue = roleEntityValue; } if (role == "AgencyCollector") { IUnitOfWork uo = new UnitOfWork("CCATDBEntities"); IRepository <aspnet_Users> repo = uo.Repository <aspnet_Users>(); aspnet_Users user = repo.GetById(new Guid(userId)); user.ManagerId = new Guid(agencyManager); repo.Update(user); uo.Save(); } } catch (Exception ex) { throw ex; } }
public async Task <AccountModel> GetAccountInfo(AccountProfile profile) { string profileStr = ""; profileStr = await profile.Client.GetStringAsync("https://ddownload.com/?op=my_account"); if (!profileStr.Contains("Affiliate link")) { profile.Model.IsPremium = false; profile.Model.TrafficLeft = 0; profile.Model.TrafficLeftWeek = 0; return(profile.Model); } if (profileStr.Contains("value=\"(Free Account)\"")) { profile.Model.IsPremium = false; profile.Model.TrafficLeft = 0; profile.Model.TrafficLeftWeek = 0; return(profile.Model); } profile.Model.IsPremium = true; Regex reg = new Regex("<div class=\"price\"><sup>$</sup>([0-9]*)0</div>"); float guthaben = float.Parse(reg.Match(profileStr).Groups[1].Value.Trim().Replace('.', ',')); profile.Model.Credit = guthaben; if (profile.Model.IsPremium) { reg = new Regex("Premium Account (bis ([0-9]{1,2} [a-zA-Z]* [0-9]{4}))"); string validdate = reg.Match(profileStr).Groups[1].Value.Trim(); profile.Model.ValidTill = DateTime.Parse(validdate); reg = new Regex("1 Tag: <img src='(.*)' alt='' width='16' height='16' title='([0-9]*)% verfügbar \\((.*) GiB\\)"); float traffic1 = float.Parse(reg.Match(profileStr).Groups[3].Value.Trim().Replace('.', ',')); reg = new Regex("7 Tage: <img src='(.*)' alt='' width='16' height='16' title='([0-9]*)% verfügbar \\((.*) GiB\\)"); float traffic7 = float.Parse(reg.Match(profileStr).Groups[3].Value.Trim().Replace('.', ',')); profile.Model.TrafficLeft = traffic1; profile.Model.TrafficLeftWeek = traffic7; } else { profile.Model.TrafficLeft = 0; profile.Model.TrafficLeftWeek = 0; } return(profile.Model); }
public async Task <int> UpdateAsync(int id, AccountProfile model) { var data = await ReadByIdAsync(id); data.Dob = model.Dob; data.Email = model.Email; data.Fullname = model.Fullname; data.Gender = model.Gender; data.EmployeeID = model.EmployeeID; data.Religion = model.Religion; DbSet.Update(data); return(await DbContext.SaveChangesAsync()); }
public ActionResult UpdateTrainerProfile() { var userIdCurrent = User.Identity.GetUserId(); ApplicationUser userView = _context.Users.FirstOrDefault(x => x.Id == userIdCurrent); var trainerProFile = _context.Trainers.SingleOrDefault(t => t.Id == userView.Id); var trainerInFor = new AccountProfile() { UsersView = userView, TrainersView = trainerProFile }; return(View(trainerInFor)); }
public async Task <AccountModel> GetAccountInfo(AccountProfile profile) { string profileStr = ""; profileStr = await profile.Client.GetStringAsync("https://ddownload.com/?op=my_account"); if (!profileStr.Contains("Affiliate link")) { profile.Model.IsPremium = false; profile.Model.TrafficLeft = 0; profile.Model.TrafficLeftWeek = 0; return(profile.Model); } if (profileStr.Contains("value=\"(Free Account)\"")) { profile.Model.IsPremium = false; profile.Model.TrafficLeft = 0; profile.Model.TrafficLeftWeek = 0; return(profile.Model); } profile.Model.IsPremium = true; Regex reg = new Regex("<div class=\"price\">" + @"<sup>($|€){1}</sup>([0-9]+)</div>"); float guthaben = float.Parse(reg.Match(profileStr).Groups[2].Value.Trim().Replace('.', ',')); profile.Model.Credit = guthaben; if (profile.Model.IsPremium) { //"Premium Account (expires 6 July 2020)" > reg = new Regex("Premium Account \\(expires ([0-9]{1,2} [a-zA-Z]* [0-9]{4})\\)"); string validdate = reg.Match(profileStr).Groups[1].Value.Trim(); profile.Model.ValidTill = DateTime.Parse(validdate); reg = new Regex("<div class=\"price\"><sup>MB</sup>([0-9]+)</div>"); float traffic1 = float.Parse(reg.Match(profileStr).Groups[1].Value.Trim().Replace('.', ',')) / 1024; float traffic7 = 700 - traffic1; profile.Model.TrafficLeft = traffic1; profile.Model.TrafficLeftWeek = traffic7; } else { profile.Model.TrafficLeft = 0; profile.Model.TrafficLeftWeek = 0; } return(profile.Model); }
public async Task <AccountProfile> DoLogin(AccountProfile profile) { Dictionary <string, string> paras = new Dictionary <string, string>(); paras.Add("user", profile.Model.Username); paras.Add("pass", profile.Model.Password); try { HttpResponseMessage resp = await profile.Client.PostAsync("https://www.share-online.biz/user/login", new FormUrlEncodedContent(paras)); } catch (Exception) { } return(profile); }
public Guid? CreateAccountProfile(AccountProfile entity) { Guid? result = null; try { SecurityDataContext context = new SecurityDataContext(); if (entity.Id == Guid.Empty) entity.Id = Guid.NewGuid(); context.AccountProfiles.InsertOnSubmit(entity); context.SubmitChanges(); result = entity.Id; } catch { } return entity.Id; }
public void UpdateAccountProfile(AccountProfile entity) { try { SecurityDataContext context = new SecurityDataContext(); var profile = context.AccountProfiles.Where(x => x.Id == entity.Id).FirstOrDefault(); profile.Id = entity.Id; profile.FirstName = entity.FirstName; profile.LastName = entity.LastName; profile.FullName = entity.FullName; profile.Title = entity.Title; profile.JobTitle = entity.JobTitle; ; profile.IsMale = entity.IsMale; profile.IsDeleted = entity.IsDeleted; context.SubmitChanges(); } catch { } }
public void UpdateUser(string userId, string firstName, string lastName, string email, string role, string roleEntityValue) { string userName = firstName.ToLower() + "." + lastName.ToLower(); AccountProfile profile; if (!string.IsNullOrEmpty(userId)) { profile = new AccountProfile(UserEntitiesDataFactory.GetUser(Guid.Parse(userId)).UserName); UserEntitiesDataFactory.UpdateUser(userId, email); UserEntitiesDataFactory.UpdateRole(userId, role); } else { if (UserEntitiesDataFactory.IsUserExits(userName)) { userName = UserEntitiesDataFactory.GetUsername(userName); } userId = UserEntitiesDataFactory.CreateUserWithRoles(userName, email, role).ToString(); profile = new AccountProfile(userName); } profile.FirstName = firstName; profile.LastName = lastName; if (!string.IsNullOrEmpty(roleEntityValue)) profile.RoleEntityValue = roleEntityValue; }