public User Create(User user, string password) { // validation if (string.IsNullOrWhiteSpace(password)) { throw new AppException("Password is required"); } if (_context.Users.Any(x => x.Phone == user.Phone)) { throw new AppException("Phone \"" + user.Phone + "\" is already taken"); } byte[] passwordHash, passwordSalt; CreatePasswordHash(password, out passwordHash, out passwordSalt); user.PasswordHash = passwordHash; user.PasswordSalt = passwordSalt; var profile = new ProfileUser(); user.Profile = profile; _context.Users.Add(user); _context.SaveChanges(); return(user); }
/// <summary> /// Gets current users profile. /// </summary> /// <returns> /// The current users profile. /// </returns> public async Task <ProfileUser> GetProfile() { try { if (Profile != null) { return(Profile); } else { var spotify = await Authentication.GetSpotifyClientAsync(); if (spotify != null) { var user = await spotify.UserProfile.Current(); Windows.UI.Xaml.Media.ImageSource image = null; if (user.Images != null) { image = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri(user.Images.FirstOrDefault().Url)); } Profile = new ProfileUser(user.Id, user.DisplayName, image); return(Profile); } return(null); } } catch (Exception e) { ViewModels.Helpers.DisplayDialog("Error", e.Message); return(null); } }
public static bool CreateProfileUserScopeIsValid(this ProfileUser profile) { return(AssertionConcern.IsSatisfiedBy( AssertionConcern.AssertNotEmpty(profile.Profile, "O profile é obrigatorio"), AssertionConcern.AssertLength(profile.Profile, 3, 20, " A quantidade de caracter é inválida") )); }
public ProfileUser Get(string username) { var user = bridge.GetUser(username); if (user == null) { return(null); } var profile = new ProfileUser { Name = username, Email = user.Email }; var clientSettings = user.DetailCollections["Settings"]; foreach (var setting in clientSettings.Details) { if (setting.Meta != null) { profile.Settings[setting.Meta] = setting.Value; } } return(profile); }
public async Task <ProfileModel> GetUserProfile(Guid userId) { ProfileUser user = await UserRetrievingService.GetById(userId); ProfileModel profile = Mapper.Map <ProfileUser, ProfileModel>(user); SetIsSelf(profile); return(profile); }
public async Task <HttpMessage <string> > ChangePass(ProfileUser profile_user) => await TryCatchResponseAsync(async() => { HttpMessage <string> result = await Json.PostAsync <HttpMessage <string>, ProfileUser>(AppSettings.AccountService.Server, AppSettings.AccountService.ApiAccount + "/changepass", profile_user, onError: (e) => { result = CreateResponseError <string>(e); }); return(result); });
public string addRegister(ProfileUser value) { //Seq = Context.DbExam.Where(i => i.ExamType == value.ExamType).Max(i => i.Seq) + 1; int UserID; // UserID = Context.ProfileUser.Where(i => i.UserId == value).Max(i => i.UserId) + 1; return("UserID"); }
private void btnProfile_Click(object sender, EventArgs e) { SlidePanel2.Height = btnProfile.Height; SlidePanel2.Top = btnProfile.Top; ProfileUser pf = new ProfileUser(); UserControlPanel2.Controls.Add(pf); pf.Dock = DockStyle.Fill; pf.BringToFront(); }
public bool AddProfile(out string outputs, string filename, string @interface = null, ProfileUser profileUser = null) { return(Execute("add profile" + ParameterUtil.Required(nameof(filename), filename, true) + ParameterUtil.Optional(nameof(@interface), @interface, true) + ParameterUtil.Optional(nameof(profileUser), profileUser), out outputs)); }
public ProfileUser Create(CreateProfileUserCommand command) { var profile = new ProfileUser(command.Profile); profile.Register(); _repository.Create(profile); if (Commit()) { return(profile); } return(null); }
public async Task <ProfileModel> Edit([FromBody] ProfileModel editModel) { ProfileUser user = await UserRetrievingService.GetByUserName(User.Identity.Name); if (editModel.Id != user.Id) { throw new InvalidOperationException("You cannot edit current profile"); } ProfileUser editedUser = Mapper.Map(editModel, user); await UserManager.UpdateAsync(editedUser); return(editModel); }
public void Save(ProfileUser profile) { var user = bridge.GetUser(profile.Name); if (user == null) { user = bridge.CreateUser(profile.Name, Guid.NewGuid().ToString(), profile.Email, Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), false, profile.Name); } var clientSettings = user.DetailCollections["Settings"]; clientSettings.Replace(profile.Settings); bridge.Save(user); }
public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context) { ProfileUser user = await _userManager.FindAsync(context.UserName, context.Password); if (user is null) { context.SetError("invalid_grant", "The user name or password is incorrect."); return; } var identity = new ClaimsIdentity(context.Options.AuthenticationType); identity.AddClaim(new Claim(ClaimTypes.Name, context.UserName)); context.Validated(identity); }
private async Task AddCurrentUserAsDocumentReviewer(DocumentModel document) { string selfName = User.Identity.Name; ProfileUser self = await UserRetrievingService.GetByUserName(selfName); Guid selfId = self.Id; if (document.Reviewers.All(e => e.UserName != selfName)) { document.Reviewers.Add( new ProfileModel() { Id = selfId }); } }
private void HomePage_Load(object sender, EventArgs e) { if (MainForm.ID_USER == 0) { Application.Exit(); } else { SlidePanel2.Height = btnProfile.Height; SlidePanel2.Top = btnProfile.Top; ProfileUser pf = new ProfileUser(); UserControlPanel2.Controls.Add(pf); pf.Dock = DockStyle.Fill; pf.BringToFront(); } }
public HttpMessage <string> ChangePass(ProfileUser profile_user) { return(TryCatchResponse(() => { if (profile_user == null || string.IsNullOrEmpty(profile_user.Email)) { throw new Exception("Неверные параметры для изменения пароля."); } List <User> users = GetUsers(profile_user.Email); if (users == null || users.Count == 0) { throw new Exception("Пользователь не найден."); } User user = GetUserByPass(Password.ComputeHash(profile_user.Pass), users); if (user == null) { throw new Exception("Неверно указан пароль."); } if (string.IsNullOrEmpty(profile_user.ChangePass)) { throw new Exception("Не указан новый пароль."); } switch (Password.Check(profile_user.ChangePass)) { case 1: throw new Exception("Пароль слишком короткий."); case 2: throw new Exception("Не указан хотя бы один заглавный символ."); case 3: throw new Exception("Не указан хотя бы один прописной символ."); case 4: throw new Exception("Не указана хотя бы одна цифра."); default: break; } SetPassword(users[0], users[0].Email, profile_user.ChangePass, "Изменение пароля в Auto Parts Site"); return CreateResponseOk("Ok"); })); }
/// <summary> /// Checks if the current user has been authenticated with a valid access token if any. /// </summary> /// <returns> /// True if authenticated, false othewise /// </returns> public async Task <bool> IsAuthenticated() { try { var currentUser = await Authentication.IsAuthenticated(); Windows.UI.Xaml.Media.ImageSource image = null; if (currentUser.Images != null) { image = new BitmapImage(new Uri(currentUser.Images.FirstOrDefault().Url)); } Profile = new ProfileUser(currentUser.Id, currentUser.DisplayName, image); return(true); } catch (Exception) { return(false); } }
public async Task <IHttpActionResult> Register([FromBody] RegisterModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } ProfileUser user = Mapper.Map <RegisterModel, ProfileUser>(model); IdentityResult result = await UserManager.CreateAsync(user, user.Password); if (result.Succeeded) { return(Ok()); } foreach (var resultError in result.Errors) { ModelState.AddModelError(string.Empty, resultError); } return(BadRequest(ModelState)); }
//this Function gets all profile and data from the user contact list and saved in a cash system void GetProfileWorker_DoWork(object sender, DoWorkEventArgs e) { try { if (GetProfileWorker.CancellationPending == true) { e.Cancel = true; } else { string aa = File.ReadAllText(Settings.UserID); string bb = File.ReadAllText(Settings.SessionID); string cc = File.ReadAllText(Settings.UserID); string TextID = aa.Replace("\r\n", ""); string sessionIDText = bb.Replace("\r\n", ""); string userprofile = bb.Replace("\r\n", ""); using (var client = new WebClient()) { var values = new NameValueCollection(); values["user_id"] = TextID; values["user_profile_id"] = userprofile; values["s"] = sessionIDText; var ChatusersListresponse = client.UploadValues(Settings.WebsiteUrl + "/app_api.php?type=get_users_list", values); var ChatusersListresponseString = Encoding.Default.GetString(ChatusersListresponse); var dictChatusersList = new JavaScriptSerializer().Deserialize <Dictionary <string, object> >(ChatusersListresponseString); string ApiStatus = dictChatusersList["api_status"].ToString(); if (ApiStatus == "200") { var s = new System.Web.Script.Serialization.JavaScriptSerializer(); var gg = dictChatusersList["users"]; var Profiles = JObject.Parse(ChatusersListresponseString).SelectToken("users").ToString(); Object obj = s.DeserializeObject(Profiles); JArray Profileusers = JArray.Parse(Profiles); string PostProfiles = ""; foreach (var ProfileUser in Profileusers) { JObject ProfileUserdata = JObject.FromObject(ProfileUser); var Profile_User_ID = ProfileUserdata["user_id"].ToString(); PostProfiles += Profile_User_ID + ","; } //Result of all profiles and friends of the user Account splited by (,) string result = PostProfiles; values["user_id"] = TextID; values["usersIDs"] = result; values["s"] = sessionIDText; var ProfileListPost = client.UploadValues(Settings.WebsiteUrl + "app_api.php?type=get_multi_users", values); var ProfileListPostresponseString = Encoding.Default.GetString(ProfileListPost); var dictProfileList = new JavaScriptSerializer().Deserialize <Dictionary <string, object> >(ProfileListPostresponseString); string ApiStatus2 = dictProfileList["api_status"].ToString(); if (ApiStatus2 == "200") { gg = dictProfileList["users"]; Profiles = JObject.Parse(ProfileListPostresponseString).SelectToken("users").ToString(); obj = s.DeserializeObject(Profiles); Profileusers = JArray.Parse(Profiles); foreach (var ProfileUser in Profileusers) { JObject ProfileUserdata = JObject.FromObject(ProfileUser); var Profile_User_ID = ProfileUserdata["user_id"].ToString(); var path = Settings.FolderDestination + Settings.SiteName + @"\Data\" + Profile_User_ID + @"\"; var path2 = Settings.FolderDestination + Settings.SiteName + @"\Data\" + Profile_User_ID + @"\" + Profile_User_ID + ".json"; if (CashSystem(path2) == "0") { DirectoryInfo di = Directory.CreateDirectory(path); string Json = ProfileUser.ToString(); System.IO.File.WriteAllText(path2, Json); } else { string Json = ProfileUser.ToString(); System.IO.File.WriteAllText(path2, Json); } var Profile_Cover = ProfileUserdata["cover"].ToString(); string lastItemOfSplit = Profile_Cover.Split('/').Last(); var Coverpath = Settings.FolderDestination + Settings.SiteName + @"\ImageCash\" + Profile_User_ID + @"\"; var Coverpath2 = Coverpath + lastItemOfSplit; if (CashSystem(Coverpath2) == "0") { if (!Directory.Exists(Coverpath)) { DirectoryInfo di = Directory.CreateDirectory(Coverpath); } client.DownloadFile(Profile_Cover, Coverpath2); } } } } } } } catch { } }
public IActionResult addRegister(ProfileUser data) { return(Ok(IPage.addRegister(data))); }
private void PerfilUsuario_Load(object sender, EventArgs e) { ClaseUsuario objUsuarios = new ClaseUsuario(Program.miUsuario); ClaseUsuario encontradoUsuarios = (ClaseUsuario)Program.objArbolAvl.buscarUsuario(objUsuarios).valorNodo(); TablaDispercionColision.miCola.Clear(); encontradoUsuarios.tablaHashSeguidos.Mostar(); int auxCont = 0; foreach (string item in TablaDispercionColision.miCola) { string[] palabras = item.ToString().Split(','); if (auxCont == 0) { pictureBox8.WaitOnLoad = false; pictureBox8.LoadAsync(@"" + palabras[0]); } else if (auxCont == 1) { pictureBox14.WaitOnLoad = false; pictureBox14.LoadAsync(@"" + palabras[0]); } else if (auxCont == 2) { pictureBox15.WaitOnLoad = false; pictureBox15.LoadAsync(@"" + palabras[0]); } else if (auxCont == 3) { pictureBox16.WaitOnLoad = false; pictureBox16.LoadAsync(@"" + palabras[0]); } else if (auxCont == 4) { pictureBox17.WaitOnLoad = false; pictureBox17.LoadAsync(@"" + palabras[0]); } auxCont++; } miXml = new AuxXml(); miXmlTemp = new AuxXml(); PanelOpciones.Visible = false; //miXmlTemp.leerXml("UsuarioTemp"); using (XmlReader reader = XmlReader.Create(@"UsuarioTemp.xml")) { while (reader.Read()) { if (reader.IsStartElement()) { //return only when you have START tag switch (reader.Name.ToString()) { case "Nombre": lbNombre.Text = reader.ReadString(); break; case "Usuario": lbUsuario.Text = reader.ReadString(); break; case "Biografia": // lbDescripcion.Text = reader.ReadString(); break; case "Correo": break; case "Img": ProfileUser.WaitOnLoad = false; ProfileUser.LoadAsync(@"" + reader.ReadString()); break; case "Publicaciones": break; } } } } //string phrase = ArbolAvl.rcInorden(Program.objArbolAvl.raizArbol()); //string[] arrayUsuarios = phrase.Split(';'); string[] arrayUsuarios = ArbolAvl.rcInorden(Program.objArbolAvl.raizArbol()).Split(';'); Random r = new Random(); int cont = 1; //int auxcont = 0; for (int i = 0; i < 4; i++) { //Genera un numero entre 10 y 100 (101 no se incluye) // Console.WriteLine(r.Next(0, 3)); if (cont == 1) { string[] arrUsuario = arrayUsuarios[r.Next(0, arrayUsuarios.Length - 1)].Split(','); if (arrUsuario[1] != Program.miUsuario) { pictureBox4.WaitOnLoad = false; pictureBox4.LoadAsync(@"" + arrUsuario[0]); label2.Text = arrUsuario[1]; cont++; } } else if (cont == 2) { string[] arrUsuario = arrayUsuarios[r.Next(0, arrayUsuarios.Length - 1)].Split(','); if (arrUsuario[1] != Program.miUsuario) { pictureBox5.WaitOnLoad = false; pictureBox5.LoadAsync(@"" + arrUsuario[0]); label3.Text = arrUsuario[1]; cont++; } } else if (cont == 3) { string[] arrUsuario = arrayUsuarios[r.Next(0, arrayUsuarios.Length - 1)].Split(','); if (arrUsuario[1] != Program.miUsuario) { pictureBox6.WaitOnLoad = false; pictureBox6.LoadAsync(@"" + arrUsuario[0]); label4.Text = arrUsuario[1]; cont++; } } else if (cont == 4) { string[] arrUsuario = arrayUsuarios[r.Next(0, arrayUsuarios.Length - 1)].Split(','); if (arrUsuario[1] != Program.miUsuario) { pictureBox7.WaitOnLoad = false; pictureBox7.LoadAsync(@"" + arrUsuario[0]); label5.Text = arrUsuario[1]; cont++; } } else { i--; } } ClaseUsuario objUsuario = new ClaseUsuario(Program.miUsuario); ClaseUsuario encontradoUsuario = (ClaseUsuario)Program.objArbolAvl.buscarUsuario(objUsuario).valorNodo(); TablaDispercionColision.miCola.Clear(); Eliminar(); encontradoUsuario.tablaHashSeguidos.Mostar(); Program.navPublicaciones.vaciar(); //Perfiles/alejandro/Prueba.jpg,alejandro string cadenaId = ""; foreach (var item in TablaDispercionColision.miCola) { string[] palabras = item.ToString().Split(','); cadenaId = cadenaId + palabras[1] + ","; } miXml.leerPublicaciones(cadenaId, "UsuariosInsta"); buscarLista(); }
public void Create(ProfileUser profile) { _context.ProfileUser.Add(profile); }
public ProfileUserWrapper(ProfileUser thebrain) { TheUser = thebrain; }
public void Update(ProfileUser profile) { _context.Entry <ProfileUser>(profile).State = EntityState.Modified; }
public void Delete(ProfileUser profile) { _context.ProfileUser.Remove(profile); }
public async Task EnsureSeedDataAsync() { if (await _userManager.FindByEmailAsync("*****@*****.**") == null) { //add the user var newUser = new ProfileMakerUser() { UserName = "******", Email = "*****@*****.**" }; IdentityResult result = await _userManager.CreateAsync(newUser, "Apelsin!0038"); if (result.Succeeded) { //await SignInAsync(user, isPersistent: false); //return RedirectToAction("Index", "Home"); } else { //AddErrors(result); } } if (!_context.ProfileUsers.Any()) { //Add new data var newProfileUser = new ProfileUser() { FirstName = "Mathias", LastName = "Claesson", Email = "*****@*****.**", UserName = "******", UserImage = "ImagePath/set/later/in/project", CompanyName = "CA Advertising AB", Address = "Hammarby Allé 132", PostNumber = 12066, City = "Stockholm", Country = "Sverige", Created = DateTime.Now, Summary = "Pluggar på LNU och är klar till sommaren. Lever med sambo och två barn!", OtherCourses = new List <OtherCourse>() { new OtherCourse() { Name = "SQL Server", Order = 1 }, new OtherCourse() { Name = "Webb of Scrum", Order = 2 } }, TechniqueAreas = new List <TechniqueArea>() { new TechniqueArea() { Name = "HTML5", Order = 1 }, new TechniqueArea() { Name = "CSS", Order = 2 }, new TechniqueArea() { Name = "PHP", Order = 4 }, new TechniqueArea() { Name = "Ruby", Order = 5 } }, Educations = new List <Education>() { new Education() { Name = "Elprogrammet inriktning data, Gymnasiet - Eksjö", StartDate = new DateTime(2006, 01, 01), StopDate = new DateTime(2008, 12, 01), Order = 1 }, new Education() { Name = "Webbprogrammerare Linnéuniversitetet", StartDate = new DateTime(2009, 01, 01), StopDate = new DateTime(2010, 12, 01), Order = 1 } }, ProjectExperiences = new List <ProjectExperience>() { new ProjectExperience() { Name = "Polisen.se", StartDate = new DateTime(2012, 01, 01), StopDate = new DateTime(2013, 12, 01), Summary = "Jobbade som en kung och fixade biffen!", TechnicalEnvironments = new List <TechnicalEnvironment>() { new TechnicalEnvironment() { Name = "ASP.NET MVC", Order = 1 }, new TechnicalEnvironment() { Name = "Visual Studio 2013", Order = 2 } }, Order = 1 }, new ProjectExperience() { Name = "ICA.se", StartDate = new DateTime(2014, 01, 01), StopDate = new DateTime(2016, 12, 01), Summary = "Jobbade som en biff och köpte mjölken!", TechnicalEnvironments = new List <TechnicalEnvironment>() { new TechnicalEnvironment() { Name = "HTML5", Order = 1 }, new TechnicalEnvironment() { Name = "PHP", Order = 2 } }, Order = 1 }, }, }; //Main obj _context.ProfileUsers.Add(newProfileUser); //list to main _context.OtherCourses.AddRange(newProfileUser.OtherCourses); _context.TechniqueAreas.AddRange(newProfileUser.TechniqueAreas); _context.Educations.AddRange(newProfileUser.Educations); //nest obj add to main _context.ProjectExperiences.AddRange(newProfileUser.ProjectExperiences); _context.SaveChanges(); } }
public ProfileProperty(ProfileUser pUser, string pName) { User = pUser; Name = pName; }