public bool UpdateProfile(ProfileEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Profiles .Single(e => e.UserID == model.UserID); entity.UserID = model.UserID; entity.FirstName = model.FirstName; entity.LastName = model.LastName; entity.PhoneNumber = model.PhoneNumber; entity.Email = model.Email; if (model.Photo != null) { MemoryStream target = new MemoryStream(); model.Photo.InputStream.CopyTo(target); byte[] data = target.ToArray(); entity.Photo = data; } return(ctx.SaveChanges() == 1); } }
public ActionResult Edit(ProfileEdit model) { var userId = Guid.Parse(User.Identity.GetUserId()); if (!ModelState.IsValid) { return(View(model)); } if (model.UserID != userId.ToString()) { ModelState.AddModelError("", "IDMismatch"); return(View(model)); } var service = new ProfilesService(userId); if (service.UpdateProfile(model)) { TempData["SaveResult"] = "Your Profile has been updated!"; return(RedirectToAction("Details", new { id = userId })); } ModelState.AddModelError("", "Your Profile could not be updated."); return(View(model)); }
public async Task <Profile> SaveProfile(double latitude, double longitude) { var token = this.localData.AccessToken(); var p = new ProfileEdit() { Latitude = latitude, Longitude = longitude, AccessToken = token.AccessToken, }; var url = string.Format(apiUrlFormat, "/profile/save"); Profile profile = null; try { profile = await this.http.Post <Profile>(url, p); } catch (UnauthorizedAccessException) { this.SessionEnded(); } catch { this.NoInternetConnection(); } return(profile); }
public ActionResult Edit(int id) { IProfileDAC dac = new ProfileDAC(); var profile = dac.GetProfile(id); var model = new ProfileEdit { ProfileID = profile.ProfileID, Name = profile.Name, ProfileText = profile.ProfileText, SortOrder = profile.SortOrder }; return(View(model)); }
public ActionResult Edit(ProfileEdit model) { if (ModelState.IsValid) { var result = _profileService.Edit(model); return(RedirectToAction("Index", "Home")); } return(View(model)); }
// GET: /Manage/Profile public ActionResult Edit() { var userId = User.Identity.GetUserId(); ApplicationUser user = UserManager.FindById(User.Identity.GetUserId()); ProfileEdit model = new ProfileEdit(); model.name = user.Name; model.email = user.Email; return(View(model)); }
public ActionResult Edit(ProfileEdit profile) { if (!ModelState.IsValid) { return(View(profile)); } IProfileDAC dac = new ProfileDAC(); dac.Update(profile.ProfileID, profile.Name, profile.ProfileText, profile.SortOrder); return(RedirectToAction("Index")); }
public bool Edit(ProfileEdit edit) { var model = ProfileRepository.GetAll().First(c => c.Id == edit.Id); model.UserName = edit.Login; model.PhoneNumber = edit.Phone; model.Email = edit.Email; model.ImageUrl = edit.ImageUrl; ProfileRepository.Save(); return(true); }
public ProfileEdit GetEdit(string id) { var model = ProfileRepository.GetAll().First(c => c.Id == id); var vm = new ProfileEdit() { Id = model.Id, Phone = model.PhoneNumber, Email = model.Email, ImageUrl = model.ImageUrl, Login = model.UserName }; return(vm); }
public ActionResult Edit(int id) { var service = CreateProfileService(); var detail = service.GetProfileById(id); var model = new ProfileEdit { ProfileId = detail.ProfileId, EmployeeId = detail.EmployeeId, QualificationId = detail.QualificationId }; return(View(model)); }
public ActionResult Edit(int id) { var service = CreateProfileService(); var detail = service.GetProfileByID(id); var model = new ProfileEdit { ProfileID = detail.ProfileID, FirstName = detail.FirstName, LastName = detail.LastName, FavTeam = detail.FavTeam }; return(View(model)); }
public bool UpdateProfile(ProfileEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Profiles .Single(e => e.ProfileId == model.ProfileId && e.Id == _userId); entity.ProfileName = model.ProfileName; entity.Phone = model.Phone; entity.Email = model.Email; return(ctx.SaveChanges() == 1); } }
public bool UpdateProfile(ProfileEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Profiles .Single(e => e.UserID == model.UserID && e.UserID == _userID); entity.Name = model.Name; entity.Email = model.Email; entity.UserID = model.UserID; //entity.ModifiedUtc = DateTimeOffset.UtcNow; return(ctx.SaveChanges() == 1); } }
// Update - Edit the profile public ActionResult Edit(int id) { var service = CreateProfileService(); var detail = service.GetProfileById(id); var model = new ProfileEdit { ProfileId = detail.ProfileId, FirstName = detail.FirstName, LastName = detail.LastName, Motivation = detail.Motivation }; return(View(model)); }
// Update - Put public bool UpdateProfile(ProfileEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Profiles .SingleOrDefault(e => e.ProfileId == model.ProfileId); entity.FirstName = model.FirstName; entity.LastName = model.LastName; entity.Motivation = model.Motivation; return(ctx.SaveChanges() == 1); } }
public IHttpActionResult Put(ProfileEdit profile) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateProfileService(); if (!service.UpdateProfile(profile)) { return(InternalServerError()); } return(Ok()); }
public bool UpdateProfile(ProfileEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Profiles .Single(e => e.ProfileID == model.ProfileID && e.OwnerID == _userId); entity.FirstName = model.FirstName; entity.LastName = model.LastName; entity.FavTeam = model.FavTeam; return(ctx.SaveChanges() == 1); } }
public bool UpdateProfile(ProfileEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx.Profiles.Single(e => e.ID == _userId); entity.Username = model.Username; entity.FirstName = model.FirstName; entity.LastName = model.LastName; entity.City = model.City; entity.State = model.State; entity.ZipCode = model.ZipCode; entity.ProfilePicture = model.GetProfilePicture; return(ctx.SaveChanges() == 1); } }
public ActionResult Edit() { var service = CreateProfileService(); var detail = service.GetProfile(); var model = new ProfileEdit { Username = detail.Username, FirstName = detail.FirstName, LastName = detail.LastName, City = detail.City, State = detail.State, ZipCode = detail.ZipCode, }; return(View(model)); }
public ActionResult Edit() { var userId = Guid.Parse(User.Identity.GetUserId()); var service = new ProfilesService(Guid.Parse(User.Identity.GetUserId())); var detail = service.GetProfileByUserID(userId.ToString()); var model = new ProfileEdit { UserID = detail.UserID, FirstName = detail.FirstName, LastName = detail.LastName, PhoneNumber = detail.PhoneNumber, Email = detail.Email }; return(View(model)); }
public bool UpdateProfile(ProfileEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Profiles .Single(e => e.ProfileId == model.ProfileId && e.OwnerId == _userId); entity.ProfileId = model.ProfileId; entity.OwnerId = model.OwnerId; entity.EmployeeId = model.EmployeeId; entity.QualificationId = model.QualificationId; entity.ModifiedUtc = DateTimeOffset.UtcNow; return(ctx.SaveChanges() == 1); } }
public ActionResult Edit(ProfileEdit model) { if (!ModelState.IsValid) { return(View(model)); } var service = CreateProfileService(); if (service.UpdateProfile(model)) { TempData["SaveResult"] = "Your profile was updated."; return(RedirectToAction("Index")); } ModelState.AddModelError("", "Your profile could not be updated."); return(View(model)); }
public PartialViewResult ProfileProfile(ProfileEdit profileEdit) { var user = db.UserProfiles.FirstOrDefault(x => x.UserID == HttpContext.GetCurrentUserUID()); if (user != null) { var names = profileEdit.Name.Split <string>(" ").ToList(); if (names.Count() > 1) { user.Patrinomic = names.ElementAt(1); } user.Name = names.ElementAt(0); user.Surname = profileEdit.Surname; user.MobilePhone = profileEdit.Phone; if (user.Email != profileEdit.Email) { user.MembershipUser.Email = profileEdit.Email; } if (profileEdit.OldPassword.IsFilled()) { if (profileEdit.NewPassword != profileEdit.NewPasswordConfirm) { ViewBag.Message = "Новый пароль и подтверждение пароля не совпадают"; } else if (!profileEdit.NewPassword.IsFilled() || profileEdit.NewPassword.Length < 6) { ViewBag.Message = "Длина пароля должна быть не менее 6 символов"; } else { if (!user.MembershipUser.ChangePassword(profileEdit.OldPassword, profileEdit.NewPassword)) { ViewBag.Message = "Старый пароль указан неверно"; } } } } if (ViewBag.Message == null) { ViewBag.Message = "Данные сохранены"; } db.SubmitChanges(); return(PartialView()); }
public bool UpdateProfile(ProfileEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Profile .Single(e => e.ProfileId == model.ProfileId); entity.UserName = model.UserName; entity.MembershipLevel = model.MembershipLevel; entity.RenewalDate = model.RenewalDate; entity.Email = model.Email; entity.ContactPreference = model.ContactPreference; return(ctx.SaveChanges() == 1); } }
public bool UpdateProfile(ProfileEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Profile .Single(e => e.ProfileID == model.ProfileID && e.UserID == model.UserID); entity.FirstName = model.FirstName; entity.LastName = model.LastName; entity.Birthday = model.Birthday; entity.Email = model.Email; entity.PhoneNumber = model.PhoneNumber; entity.OtherInfo = model.OtherInfo; entity.MyTeams = model.MyTeams; entity.Comments = model.Comments; return(ctx.SaveChanges() == 1); } }
public bool Edit(ProfileEdit edit) { using (var ctx = new ApplicationDbContext()) { var oldProfile = ctx.Profiles .Single(e => e.UserID == _userId.ToString()); oldProfile.FirstName = edit.FirstName; oldProfile.LastName = edit.LastName; oldProfile.Email = edit.Email; oldProfile.PhoneNumber = edit.PhoneNumber; MemoryStream target = new MemoryStream(); edit.Photo.InputStream.CopyTo(target); byte[] data = target.ToArray(); oldProfile.Photo = data; return(ctx.SaveChanges() == 1); } }
public async Task <ActionResult> Edit(ProfileEdit model) { if (!ModelState.IsValid) { return(View(model)); } ApplicationUser user = UserManager.FindById(User.Identity.GetUserId()); user.Name = model.name; user.Email = model.email; IdentityResult result = await UserManager.UpdateAsync(user); if (result.Succeeded) { return(RedirectToAction("Index")); } else { return(View()); } }
public ActionResult Edit(int id, ProfileEdit model) { if (!ModelState.IsValid) { return(View(model)); } if (model.ProfileId != id) { ModelState.AddModelError("", "ID does not match one in the database, please try again."); return(View(model)); } var service = CreateProfileService(); if (service.UpdateProfile(model)) { TempData["SaveResult"] = "Your profile was successfully updated."; return(RedirectToAction("Index")); } ModelState.AddModelError("", "Your profile could not be updated, please try again."); return(View(model)); }
public ActionResult Edit(ProfileEdit form) { var user = Auth.User; if (user == null) { return(HttpNotFound()); } if (ModelState.IsValid) { user.Username = form.Username; user.Email = form.Email; user.Name = form.Name; db.Entry(user).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View("Index", new ProfileEdit { Name = user.Name, Email = user.Email, Username = user.Username })); }
internal void EditProfile() { //Populate the Excel Sheet GlobalDefinitions.ExcelLib.PopulateInCollection(Base.ExcelPath, "Profile"); Thread.Sleep(1000); //Click on Edit button ProfileEdit.Click(); //User's First Name FirstName.Clear(); FirstName.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "FirstName")); //User's Last Name LastName.Clear(); LastName.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "LastName")); //Save User's Details SaveUserDetails.Click(); //Availability Time option Thread.Sleep(1500); AvailabilityTime.Click(); AvailabilityTimeOpt.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "AvailableTime")); //Availability Hours Thread.Sleep(2000); AvailabilityHours.Click(); //Availability Hours option Availability.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Hours")); //Earn Target Thread.Sleep(2000); EarnTarget.Click(); selectTarget.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "EarnTarget")); //----------------------------------------------------- //IJavaScriptExecutor js = GlobalDefinitions.driver as IJavaScriptExecutor; //Thread.Sleep(1000); //js.ExecuteScript("window.scrollBy(0,100);"); //Thread.Sleep(1000); //--------------------------------------------------------- //Click on Add New Language button AddNewBtn.Click(); Thread.Sleep(1000); //Enter the Language AddLangText.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Language")); //Choose Language ChooseLangLevel.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Level")); Thread.Sleep(1000); AddLang.Click(); Base.test.Log(LogStatus.Info, "Added Language successfully"); //----------------------------------------------------------- //Click on Add New Skill Button SkillTab.Click(); AddNewSkillBtn.Click(); //Enter the skill AddSkillText.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Skill")); //Click the skill dropdown ChooseSkilllevel.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "SkillsLevel")); Thread.Sleep(500); //ChooseSkilllevel.Click(); AddSkill.Click(); Thread.Sleep(500); Base.test.Log(LogStatus.Info, "Added Skills successfully"); //--------------------------------------------------------- //Add Education EducationTab.Click(); AddNewEducation.Click(); //Enter the University EnterUniversity.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "University")); //Choose Country ChooseCountry.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Country")); Thread.Sleep(500); //Choose Title ChooseTitle.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Title")); Thread.Sleep(500); //Enter Degree Degree.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Degree")); //Year of Graduation DegreeYear.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "GraduateYear")); Thread.Sleep(500); AddEdu.Click(); Thread.Sleep(500); Base.test.Log(LogStatus.Info, "Added Education successfully"); //------------------------------------------------- //Click on Certificate tab CertiTab.Click(); //Click on add new AddNewCertibtn.Click(); //Enter Certificate Name CertiName.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Certificate")); //Enter Certified from CertiFrom.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "CertifiedFrom")); //Enter the Year CertiYear.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "CerYear"));; Thread.Sleep(500); //Click Add new AddCerti.Click(); Thread.Sleep(500); Base.test.Log(LogStatus.Info, "Added Certificate successfully"); //------------------------------------------------------------------------------- //Add Description ICON DescrIco.Click(); //Enter description Description.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Description")); Thread.Sleep(500); //Click on Save Save.Click(); Base.test.Log(LogStatus.Info, "Added Description successfully"); }