public void EditUserProfile_LoadUser_Method_With_1_Parameters_Call_With_Reflection_Exception_Thrown_Test() { // Arrange var user = Fixture.Create <User>(); object[] parametersOutRanged = { user, null }; object[] parametersInDifferentNumber = { }; var editUserProfile = new EditUserProfile(); var methodName = "LoadUser"; // Act var loadUserMethodInfo1 = editUserProfile.GetType().GetMethod(methodName); var loadUserMethodInfo2 = editUserProfile.GetType().GetMethod(methodName); var returnType1 = loadUserMethodInfo1.ReturnType; var returnType2 = loadUserMethodInfo2.ReturnType; // Assert parametersOutRanged.ShouldNotBeNull(); parametersInDifferentNumber.ShouldNotBeNull(); returnType1.ShouldNotBeNull(); returnType2.ShouldNotBeNull(); returnType1.ShouldBe(returnType2); editUserProfile.ShouldNotBeNull(); loadUserMethodInfo1.ShouldNotBeNull(); loadUserMethodInfo2.ShouldNotBeNull(); loadUserMethodInfo1.ShouldBe(loadUserMethodInfo2); Should.Throw <Exception>(actual: () => loadUserMethodInfo1.Invoke(editUserProfile, parametersOutRanged)); Should.Throw <Exception>(actual: () => loadUserMethodInfo2.Invoke(editUserProfile, parametersOutRanged)); Should.Throw <Exception>(actual: () => loadUserMethodInfo1.Invoke(editUserProfile, parametersInDifferentNumber)); Should.Throw <Exception>(actual: () => loadUserMethodInfo2.Invoke(editUserProfile, parametersInDifferentNumber)); Should.Throw <TargetParameterCountException>(actual: () => loadUserMethodInfo1.Invoke(editUserProfile, parametersOutRanged)); Should.Throw <TargetParameterCountException>(actual: () => loadUserMethodInfo2.Invoke(editUserProfile, parametersOutRanged)); Should.Throw <TargetParameterCountException>(actual: () => loadUserMethodInfo1.Invoke(editUserProfile, parametersInDifferentNumber)); Should.Throw <TargetParameterCountException>(actual: () => loadUserMethodInfo2.Invoke(editUserProfile, parametersInDifferentNumber)); }
public void EditUserProfile_LoadUser_Method_With_1_Parameters_Call_With_Reflection_No_Exception_Thrown_Test() { // Arrange object[] parametersOfLoadUser = { null }; var editUserProfile = new EditUserProfile(); var methodName = "LoadUser"; // Act var loadUserMethodInfo1 = editUserProfile.GetType().GetMethod(methodName); var loadUserMethodInfo2 = editUserProfile.GetType().GetMethod(methodName); var returnType1 = loadUserMethodInfo1.ReturnType; var returnType2 = loadUserMethodInfo2.ReturnType; // Assert parametersOfLoadUser.ShouldNotBeNull(); editUserProfile.ShouldNotBeNull(); returnType1.ShouldNotBeNull(); returnType2.ShouldNotBeNull(); returnType1.ShouldBe(returnType2); loadUserMethodInfo1.ShouldNotBeNull(); loadUserMethodInfo2.ShouldNotBeNull(); loadUserMethodInfo1.ShouldBe(loadUserMethodInfo2); Should.Throw <Exception>(actual: () => loadUserMethodInfo1.Invoke(editUserProfile, parametersOfLoadUser)); Should.Throw <Exception>(actual: () => loadUserMethodInfo2.Invoke(editUserProfile, parametersOfLoadUser)); }
public void EditUserProfile_SaveProfile_Method_With_No_Parameters_Call_With_Reflection_Exception_Thrown_Test() { // Arrange object[] parametersOutRanged = { null, null }; var editUserProfile = new EditUserProfile(); var methodName = "SaveProfile"; // Act var saveProfileMethodInfo1 = editUserProfile.GetType().GetMethod(methodName); var saveProfileMethodInfo2 = editUserProfile.GetType().GetMethod(methodName); var returnType1 = saveProfileMethodInfo1.ReturnType; var returnType2 = saveProfileMethodInfo2.ReturnType; // Assert parametersOutRanged.ShouldNotBeNull(); returnType1.ShouldNotBeNull(); returnType2.ShouldNotBeNull(); returnType1.ShouldBe(returnType2); editUserProfile.ShouldNotBeNull(); saveProfileMethodInfo1.ShouldNotBeNull(); saveProfileMethodInfo2.ShouldNotBeNull(); saveProfileMethodInfo1.ShouldBe(saveProfileMethodInfo2); Should.Throw <Exception>(actual: () => saveProfileMethodInfo1.Invoke(editUserProfile, parametersOutRanged)); Should.Throw <Exception>(actual: () => saveProfileMethodInfo2.Invoke(editUserProfile, parametersOutRanged)); Should.Throw <TargetParameterCountException>(actual: () => saveProfileMethodInfo1.Invoke(editUserProfile, parametersOutRanged)); Should.Throw <TargetParameterCountException>(actual: () => saveProfileMethodInfo2.Invoke(editUserProfile, parametersOutRanged)); }
public void Update(EditUserProfile editUser) { var user = _unitOfWork.UserRepository.Get(u => u.UserId == editUser.UserId).First(); var profile = _unitOfWork.ProfileRepository.Get(p => p.Type == (Enums.Profile.ProfileType)editUser.ProfileType).First(); user.Status = (Enums.User.UserStatus)editUser.Status; user.ProfileId = profile.ProfileId; _unitOfWork.UserRepository.Edit(user); _unitOfWork.Commit(); }
public ActionResult Edit(EditUserProfile editUserProfile) { if (ModelState.IsValid) { MembershipUser membershipUser = Membership.GetUser(editUserProfile.UserName); membershipUser.Email = editUserProfile.Email; Membership.UpdateUser(membershipUser); new UserProfileLogic().Update(editUserProfile); return(RedirectToAction("Index")); } return(View(editUserProfile)); }
public async Task <MemberInfo> EditCurrentPlayerProfile(EditUserProfile profile) { if (!GameService.IsAuthenticated()) { throw new GameServiceException("GameService Not Available").LogException(typeof(PlayerProvider), DebugLocation.Internal, "EditCurrentPlayerProfile"); } if (profile == null) { throw new GameServiceException("profile Cant Be Null").LogException(typeof(PlayerProvider), DebugLocation.Internal, "EditCurrentPlayerProfile"); } return(await ApiRequest.EditCurrentPlayer(profile)); }
public EditUserProfile GetEditUserProfileById(int id) { using (var db = new SalesDBContext()) { var userProfile = db.UserProfiles.FirstOrDefault(u => u.ID == id); EditUserProfile editUseProfile = new EditUserProfile { FirstName = userProfile.FirstName, LastName = userProfile.LastName, UserName = userProfile.UserName, Email = userProfile.Email, Address = userProfile.Address }; return(editUseProfile); } }
public async Task <IdentityResult> UpdateProfileAsync(EditUserProfile editUserProfile) { // implement update profile var userId = _userService.GetUserId(); var user = await _userManager.FindByIdAsync(userId); if (user != null) { user.FirstName = editUserProfile.FirstName; user.LastName = editUserProfile.LastName; user.Email = editUserProfile.Email; } var result = await _userManager.UpdateAsync(user); return(result); }
public ActionResult Edit() { // Get current user UserProfile user = UserService.GetFreshUseerUpdatedFromDataBase(); if (user == null) { return(HttpNotFound()); } // Set model EditUserProfile model = new EditUserProfile { User = user, Success = null // none action done at this time }; return(View(model)); }
public async Task <IActionResult> UserProfile() { // display user data var userId = _userService.GetUserId(); var getUser = await _userManager.FindByIdAsync(userId); if (getUser == null) { return(NotFound($"Unable to load user data")); } var model = new EditUserProfile() { FirstName = getUser.FirstName, LastName = getUser.LastName, Email = getUser.Email }; return(View(model)); }
public async Task <IActionResult> UserProfile(EditUserProfile editUserProfile) { // validate and update profile form if (ModelState.IsValid) { var result = await _accountRepository.UpdateProfileAsync(editUserProfile); if (result.Succeeded) { ViewBag.IsSuccess = true; return(View(editUserProfile)); } foreach (var error in result.Errors) { ModelState.AddModelError("", error.Description); } } return(View(editUserProfile)); }
public async Task <IActionResult> OnPost(EditUserProfile profile) { LoggedInUser = await _userManager.GetUserAsync(User); UserInformation = await _context.UserInformation.FirstOrDefaultAsync(x => x.UserId.Equals(LoggedInUser.Id)); if (!ModelState.IsValid) { Profile = profile; await SetPageValues(); return(Page()); } //Update user mobile number LoggedInUser.PhoneNumber = profile.PhoneNumber; LoggedInUser.Email = profile.Email; await _userManager.UpdateAsync(LoggedInUser); if (profile.ClassName != "11th" || profile.ClassName != "12th") { profile.Subject1 = null; profile.Subject2 = null; profile.Subject3 = null; profile.Subject4 = null; profile.Subject5 = null; } //Update user information UserInformation = _mapper.Map(profile, UserInformation); UserInformation.UserId = LoggedInUser.Id; _context.UserInformation.Update(UserInformation); await _context.SaveChangesAsync(); ShowSuccess = true; await SetPageValues(); return(Page()); }
public async Task <ViewResult> Edit(EditUserProfile model) { // Test model if (ModelState.IsValid) { // Get current user from session UserProfile user = UserService.Get(); // Update editable data user.Name = model.User.Name; user.Email = model.User.Email; // update database using (var db = new DataService()) { // Try to save changes model.Success = await db.EditUser(user); // Refresh model.User = user; } } return(View(model)); }
public ActionResult EditUserProfile(EditUserProfile edituser, string allchecked, FormCollection formCollection) { try { using (DBClass context = new DBClass()) { context.AddParameter("@UserName", Session["UserName"].ToString()); context.AddParameter("@UserRole", Session["UserRole"].ToString()); context.AddParameter("@FullName", edituser.fullName); context.AddParameter("@Phone", edituser.Phone); context.AddParameter("@EmailID", edituser.Email); context.AddParameter("@Address", edituser.Address); context.AddParameter("@City", edituser.City); context.AddParameter("@State", edituser.State); context.AddParameter("@Country", edituser.Country); context.AddParameter("@CompanyName", edituser.companyName); context.AddParameter("@compAddress", edituser.compAddress); context.AddParameter("@compCity", edituser.cmpCity); context.AddParameter("@compState", edituser.cmpState); context.AddParameter("@compCountry", edituser.cmpCountry); context.AddParameter("@OfficeNo", edituser.OfficeNo); context.AddParameter("@compWebsite", edituser.cmpWebsite); context.AddParameter("@designation", edituser.Designation); context.AddParameter("@department", edituser.Department); context.AddParameter("@Graduation", edituser.graduation); context.AddParameter("@PostGraduation", edituser.postgraduation); context.AddParameter("@Certificate", edituser.certification); context.AddParameter("@Experience", edituser.Experience); context.AddParameter("@specialization", formCollection["allchecked"]); context.ExecuteNonQuery("updateUserProfile", CommandType.StoredProcedure); } } catch { } return(RedirectToAction("Home", "Home")); //return View("Index", "Home"); }
public bool Update(EditUserProfile editUserProfile) { using (var db = new SalesDBContext()) { try { var q = db.UserProfiles.FirstOrDefault(u => u.ID == editUserProfile.ID); if (q != null) { q.FirstName = editUserProfile.FirstName; q.LastName = editUserProfile.LastName; q.Email = editUserProfile.Email; q.Address = editUserProfile.Address; db.SaveChanges(); } } catch { return(false); } return(true); } }
public ActionResult EditUserProfile(string userName) { EditUserProfile edit = new EditUserProfile(); edit.specialization = ""; try { List <SelectListItem> specs = new List <SelectListItem>(); List <SelectListItem> GraduationList = new List <SelectListItem>(); List <SelectListItem> PostGraduationList = new List <SelectListItem>(); List <SelectListItem> CertificationList = new List <SelectListItem>(); List <SelectListItem> ExperienceList = new List <SelectListItem>(); List <SelectListItem> DepartmentList = new List <SelectListItem>(); GraduationList.Add(new SelectListItem { Text = "B.Arch", Value = "B.Arch" }); GraduationList.Add(new SelectListItem { Text = "BBA", Value = "BBA" }); GraduationList.Add(new SelectListItem { Text = "BCA", Value = "BCA" }); GraduationList.Add(new SelectListItem { Text = "B.A", Value = "B.A" }); GraduationList.Add(new SelectListItem { Text = "B.Com", Value = "B.Com" }); GraduationList.Add(new SelectListItem { Text = "B.Sc ", Value = "B.Sc" }); GraduationList.Add(new SelectListItem { Text = "BE", Value = "BE" }); GraduationList.Add(new SelectListItem { Text = "B.Tech", Value = "B.Tech" }); GraduationList.Add(new SelectListItem { Text = "B.Pharma", Value = "B.Pharma" }); GraduationList.Add(new SelectListItem { Text = "Other", Value = "Other" }); ViewBag.gradList = GraduationList; PostGraduationList.Add(new SelectListItem { Text = "MA", Value = "MA" }); PostGraduationList.Add(new SelectListItem { Text = "M.Com", Value = "M.Com" }); PostGraduationList.Add(new SelectListItem { Text = "MS", Value = "MS" }); PostGraduationList.Add(new SelectListItem { Text = "M.Tech", Value = "M.Tech" }); PostGraduationList.Add(new SelectListItem { Text = "MCA", Value = "MCA" }); PostGraduationList.Add(new SelectListItem { Text = "ME ", Value = "ME" }); PostGraduationList.Add(new SelectListItem { Text = "Other", Value = "Other" }); ViewBag.postgradList = PostGraduationList; CertificationList.Add(new SelectListItem { Text = "CAT-Level-1", Value = "CAT-Level-1" }); CertificationList.Add(new SelectListItem { Text = "CAT-Level-2", Value = "CAT-Level-2" }); CertificationList.Add(new SelectListItem { Text = "CAT-Level-3", Value = "CAT-Level-3" }); CertificationList.Add(new SelectListItem { Text = "CAT-Level-4", Value = "CAT-Level-4" }); CertificationList.Add(new SelectListItem { Text = "ASNT-Level-1", Value = "CAT-Level-1" }); CertificationList.Add(new SelectListItem { Text = "ASNT-Level-2", Value = "ASNT-Level-2" }); CertificationList.Add(new SelectListItem { Text = "ASNT-Level-3", Value = "ASNT-Level-3" }); CertificationList.Add(new SelectListItem { Text = "ASNT-Level-4", Value = "ASNT-Level-4" }); CertificationList.Add(new SelectListItem { Text = "BiNDT-Level-1", Value = "BiNDT-Level-1" }); CertificationList.Add(new SelectListItem { Text = "BiNDT-Level-2", Value = "BiNDT-Level-2" }); CertificationList.Add(new SelectListItem { Text = "BiNDT-Level-3", Value = "BiNDT-Level-3" }); CertificationList.Add(new SelectListItem { Text = "BiNDT-Level-4", Value = "BiNDT-Level-4" }); CertificationList.Add(new SelectListItem { Text = "Other", Value = "Other" }); ViewBag.certList = CertificationList; ExperienceList.Add(new SelectListItem { Text = "0-1 Year", Value = "0 Year" }); ExperienceList.Add(new SelectListItem { Text = "1 Year", Value = "1 Year" }); ExperienceList.Add(new SelectListItem { Text = "2 Year", Value = "2 Year" }); ExperienceList.Add(new SelectListItem { Text = "3 Year", Value = "3 Year" }); ExperienceList.Add(new SelectListItem { Text = "4 Year", Value = "4 Year" }); ExperienceList.Add(new SelectListItem { Text = "5 Year", Value = "5 Year" }); ExperienceList.Add(new SelectListItem { Text = "6 Year", Value = "6 Year" }); ExperienceList.Add(new SelectListItem { Text = "7 Year", Value = "7 Year" }); ExperienceList.Add(new SelectListItem { Text = "8 Year", Value = "8 Year" }); ExperienceList.Add(new SelectListItem { Text = "9 Year", Value = "9 Year" }); ExperienceList.Add(new SelectListItem { Text = "10 Year", Value = "10 Year" }); ExperienceList.Add(new SelectListItem { Text = "11 Year", Value = "11 Year" }); ExperienceList.Add(new SelectListItem { Text = "12 Year", Value = "12 Year" }); ExperienceList.Add(new SelectListItem { Text = "13 Year", Value = "13 Year" }); ExperienceList.Add(new SelectListItem { Text = "14 Year", Value = "14 Year" }); ExperienceList.Add(new SelectListItem { Text = "15 Year", Value = "15 Year" }); ExperienceList.Add(new SelectListItem { Text = "16 Year", Value = "16 Year" }); ExperienceList.Add(new SelectListItem { Text = "17 Year", Value = "17 Year" }); ExperienceList.Add(new SelectListItem { Text = "18 Year", Value = "18 Year" }); ExperienceList.Add(new SelectListItem { Text = "19 Year", Value = "19 Year" }); ExperienceList.Add(new SelectListItem { Text = "20 Year", Value = "20 Year" }); ExperienceList.Add(new SelectListItem { Text = "20+ Year", Value = "20+ Year" }); ViewBag.expList = ExperienceList; specs.Add(new SelectListItem { Text = "Vibration Analysis", Value = "Vibration Analysis" }); specs.Add(new SelectListItem { Text = "Thermal Analysis", Value = "Thermal Analysis" }); specs.Add(new SelectListItem { Text = "Leak Detection", Value = "Leak Detection" }); specs.Add(new SelectListItem { Text = "Balancing", Value = "Balancing" }); ViewBag.SpecList = specs; DepartmentList.Add(new SelectListItem { Text = "Sales & Marketing", Value = "Sales & Marketing" }); DepartmentList.Add(new SelectListItem { Text = "Account", Value = "Account" }); DepartmentList.Add(new SelectListItem { Text = "Admin", Value = "Admin" }); DepartmentList.Add(new SelectListItem { Text = "HR", Value = "HR" }); DepartmentList.Add(new SelectListItem { Text = "IT", Value = "IT" }); ViewBag.departmentList = DepartmentList; using (DBClass context = new DBClass()) { context.AddParameter("@UserName", Session["UserName"].ToString()); context.AddParameter("@UserRole", Session["UserRole"].ToString()); DataTable dt = context.getData("getUserDetail", CommandType.StoredProcedure); if (dt.Rows.Count > 0) { if (Session["UserRole"].ToString() == "Client") { edit.fullName = Convert.ToString(dt.Rows[0]["uName"]); edit.UserName = Convert.ToString(dt.Rows[0]["UserName"]); edit.Email = Convert.ToString(dt.Rows[0]["Email_ID"]); edit.Phone = Convert.ToString(dt.Rows[0]["uMobile_No"]); edit.Address = Convert.ToString(dt.Rows[0]["Address"]); edit.City = Convert.ToString(dt.Rows[0]["City"]); edit.State = Convert.ToString(dt.Rows[0]["State"]); edit.Country = Convert.ToString(dt.Rows[0]["Country"]); edit.imageSrc = Convert.ToString(dt.Rows[0]["ImagePath"]); edit.companyName = Convert.ToString(dt.Rows[0]["uCompanyName"]); edit.compAddress = Convert.ToString(dt.Rows[0]["uCompanyAddress"]); edit.cmpCity = Convert.ToString(dt.Rows[0]["uCity"]); edit.cmpState = Convert.ToString(dt.Rows[0]["uState"]); edit.cmpCountry = Convert.ToString(dt.Rows[0]["uCountry"]); edit.OfficeNo = Convert.ToString(dt.Rows[0]["officePhone"]); edit.cmpWebsite = Convert.ToString(dt.Rows[0]["uCompany_Website"]); } if (Session["UserRole"].ToString() == "Employee") { edit.fullName = Convert.ToString(dt.Rows[0]["Emp_Name"]); edit.UserName = Convert.ToString(dt.Rows[0]["LoginID"]); edit.Email = Convert.ToString(dt.Rows[0]["EmailId"]); edit.Phone = Convert.ToString(dt.Rows[0]["PhoneNo"]); edit.Address = Convert.ToString(dt.Rows[0]["EAddress"]); edit.City = Convert.ToString(dt.Rows[0]["ECity"]); edit.State = Convert.ToString(dt.Rows[0]["EState"]); edit.Country = Convert.ToString(dt.Rows[0]["ECountry"]); edit.Designation = Convert.ToString(dt.Rows[0]["Designation"]); edit.Department = Convert.ToString(dt.Rows[0]["Department"]); edit.imageSrc = Convert.ToString(dt.Rows[0]["Image"]); } if (Session["UserRole"].ToString() == "Consultant") { edit.fullName = Convert.ToString(dt.Rows[0]["Emp_Name"]); edit.UserName = Convert.ToString(dt.Rows[0]["LoginID"]); edit.Email = Convert.ToString(dt.Rows[0]["EmailId"]); edit.Phone = Convert.ToString(dt.Rows[0]["PhoneNo"]); edit.Address = Convert.ToString(dt.Rows[0]["EAddress"]); edit.City = Convert.ToString(dt.Rows[0]["ECity"]); edit.State = Convert.ToString(dt.Rows[0]["EState"]); edit.Country = Convert.ToString(dt.Rows[0]["ECountry"]); edit.imageSrc = Convert.ToString(dt.Rows[0]["Image"]); edit.companyName = Convert.ToString(dt.Rows[0]["CompName"]); edit.graduation = Convert.ToString(dt.Rows[0]["Graduation"]); edit.postgraduation = Convert.ToString(dt.Rows[0]["Postgraduation"]); edit.certification = Convert.ToString(dt.Rows[0]["Certification"]); edit.Experience = Convert.ToString(dt.Rows[0]["Experience"]); edit.specialization = Convert.ToString(dt.Rows[0]["Specialization"]); edit.compAddress = Convert.ToString(dt.Rows[0]["CAddress"]); edit.cmpCity = Convert.ToString(dt.Rows[0]["CCity"]); edit.cmpState = Convert.ToString(dt.Rows[0]["CState"]); edit.cmpCountry = Convert.ToString(dt.Rows[0]["CCountry"]); edit.OfficeNo = Convert.ToString(dt.Rows[0]["OfficeContactNo"]); edit.cmpWebsite = Convert.ToString(dt.Rows[0]["CompWebsite"]); } } } } catch { } return(View(edit)); }
public IActionResult EditUser([FromForm] EditUserProfile user) { _userService.Update(user); return(Ok(null)); }