public ActionResult Save(UserProfileModel model) { var login = service.GetByPin(model.Pin); if (login != null) { model.Roles = roleService.GetAll().ToSelectList(null, "Id", "RoleName"); ModelState.AddModelError("", "User has exists"); return(PartialView("Create", model)); } model.Password = "" + model.Password.ToMD5(); UserProfile entity = new UserProfile(); ModelCopier.CopyModel(model, entity); service.Add(entity); unitOfWork.Commit(); SessionHelper.Temp = null; return(PartialView()); }
/// <summary> /// PUT http://localhost:8080/api/profile/d0a0ee8d-e08b-48ad-92ea-f2a9f3fd25d8 /// </summary> /// <param name="userid"></param> /// <param name="profile"></param> /// <returns></returns> public async Task <IHttpActionResult> Post( [FromUri(Name = "id")] Guid userid, [FromBody] UserProfileModel profile) { if (Guid.Empty == userid) { return(NotFound()); } if (false == IsModelValid(profile)) { return(BadRequest()); } var user = GrainClient.GrainFactory.GetGrain <IUserProfile>(userid); await user.SetProfileAsync(new UserProfile { Name = profile.Name }); return(Created( new Uri(Url.Link("DefaultApi", new { id = userid })), new UserProfileModel { Name = profile.Name } )); }
/// <summary> /// Initializes inner controls. /// </summary> private void InitializeControl() { FieldLabel.Text = ResHelper.LocalizeString(FieldInfo.GetPropertyValue(FormFieldPropertyEnum.FieldCaption, MacroContext.CurrentResolver)); AttributeDropDownList.Items.Add(new ListItem()); foreach (EntityAttributeModel attributeModel in UserProfileModel.Items) { EntityAttributeValueConverterBase attributeValueConverter = AttributeValueConverterFactory.CreateConverter(attributeModel); if (attributeValueConverter != null && attributeValueConverter.IsCompatibleWithFormField(FieldInfo)) { ListItem item = new ListItem { Value = String.Format("{0}-{1}", GetAttributeTypeName(attributeModel), attributeModel.Name), Text = ResHelper.LocalizeString(attributeModel.DisplayName) }; AttributeDropDownList.Items.Add(item); } } if (SourceMappingItem != null) { EntityAttributeModel attributeModel = UserProfileModel.GetAttributeModel(SourceMappingItem.AttributeName); if (attributeModel != null) { AttributeDropDownList.SelectedValue = String.Format("{0}-{1}", GetAttributeTypeName(attributeModel), SourceMappingItem.AttributeName); } } }
public string GenerateJWTClientToken(UserProfileModel userProfile) { // All parameters send to Azure AD B2C needs to be sent as claims IList <System.Security.Claims.Claim> claims = new List <System.Security.Claims.Claim>(); claims.Add(new System.Security.Claims.Claim("sub", "*****@*****.**", System.Security.Claims.ClaimValueTypes.String, AppSettings.Issuer)); claims.Add(new System.Security.Claims.Claim("name", "Yoel 111", System.Security.Claims.ClaimValueTypes.String, AppSettings.Issuer)); claims.Add(new System.Security.Claims.Claim("city", userProfile.City, System.Security.Claims.ClaimValueTypes.String, AppSettings.Issuer)); string dataDir = AppDomain.CurrentDomain.GetData("CertificateDir").ToString(); X509Certificate2 cert = new X509Certificate2( Path.Combine(dataDir, AppSettings.CertificateName), AppSettings.CertificatePassword, X509KeyStorageFlags.DefaultKeySet); // create token JwtSecurityToken token = new JwtSecurityToken( AppSettings.Issuer, AppSettings.Audience, claims, DateTime.Now, DateTime.Now.AddYears(1), new X509SigningCredentials(cert)); // Get the representation of the signed token JwtSecurityTokenHandler jwtHandler = new JwtSecurityTokenHandler(); string jwtOnTheWire = jwtHandler.WriteToken(token); return(jwtOnTheWire); }
public ActionResult Profile() { string UserName = (string)Session["UserName"]; if (UserName == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } SearchOperation searchOperation = new SearchOperation(); Users user = searchOperation.GetUser(UserName); Student student = searchOperation.GetStudent(user.UserId); Address address = searchOperation.GetAddress(student.StudentId); District parDistrict = searchOperation.GetDistrict((int)address.P_DistrictId); District TemDistrict = searchOperation.GetDistrict((int)address.T_DistrictId); DepartmentInfo departmentInfo = searchOperation.GetDepartmentInfo(student.StudentId); Department department = searchOperation.GetDepartment((int)departmentInfo.DepartmentId); Room room = searchOperation.GetRoom((int)student.RoomId); UserProfileModel userProfileModel = new UserProfileModel(); userProfileModel.StudentName = student.StudentName; userProfileModel.FatherName = student.FatherName; userProfileModel.MotherName = student.MotherName; userProfileModel.MobileNumber = student.MobileNumber; userProfileModel.ParmanentDistrict = parDistrict.DistrictName; userProfileModel.ParmanentPostOfiice = address.P_PostOffice; userProfileModel.ParmanentVillage = address.P_VillageName; userProfileModel.TemporaryDistrict = TemDistrict.DistrictName; userProfileModel.TemporaryPostOfiice = address.T_PostOffice; userProfileModel.TemporaryVillage = address.T_VillageName; userProfileModel.DepartmentName = department.DeptName; userProfileModel.Session = departmentInfo.Session; userProfileModel.Cgpa = departmentInfo.Cgpa; userProfileModel.RoomNumber = (int)room.RoomNumber; return(View(userProfileModel)); }
private static void FakePrivateChatMessage(IChatController controller, string sender, string recipient, string message) { if (!UserProfileController.userProfilesCatalog.Get(recipient)) { var model = new UserProfileModel() { userId = recipient, name = recipient + "-name", }; UserProfileController.i.AddUserProfileToCatalog(model); } if (!UserProfileController.userProfilesCatalog.Get(sender)) { var model = new UserProfileModel() { userId = sender, name = sender + "-name", }; UserProfileController.i.AddUserProfileToCatalog(model); } var msg = new ChatMessage() { body = message, sender = sender, recipient = recipient, messageType = ChatMessage.Type.PRIVATE }; controller.AddMessageToChatWindow(JsonUtility.ToJson(msg)); }
public async Task <IActionResult> YourPosts(UserProfileModel upm) { var claimsidentity = (ClaimsIdentity)this.User.Identity; var claims = claimsidentity.FindFirst(ClaimTypes.NameIdentifier); if (upm.Id == null) { return(NotFound()); } if (ModelState.IsValid) { var files = HttpContext.Request.Form.Files; if (files.Count() > 0) { byte[] pic = null; using (var filestream = files[0].OpenReadStream()) { using (var memorystream = new MemoryStream()) { filestream.CopyTo(memorystream); pic = memorystream.ToArray(); } } upm.ProfilePicture = pic; } upm.UserId = claims.Value; _db.UserProfileModel.Add(upm); await _db.SaveChangesAsync(); return(RedirectToAction(nameof(YourPosts))); } return(View(upm)); }
public async Task <UserProfileModel> SaveStaffProfileAsync(int staffUsi, UserProfileModel model) { var profile = await(from s in _edFiDb.StaffProfiles .Include(x => x.StaffProfileAddresses.Select(y => y.AddressType)) .Include(x => x.StaffProfileElectronicMails.Select(y => y.ElectronicMailType)) .Include(x => x.StaffProfileTelephones.Select(y => y.TelephoneNumberType)) from staff in _edFiDb.Staffs.Where(x => x.StaffUniqueId == s.StaffUniqueId).DefaultIfEmpty() where staff.StaffUsi == staffUsi select new StaffProfileModel { Staff = staff, Profile = s }).SingleOrDefaultAsync(); // If the parent portal extended profile is not null remove it and add it again with the submitted changes. if (profile.Profile != null) { _edFiDb.StaffProfiles.Remove(profile.Profile); } var newProfile = await AddNewProfileAsync(profile.Staff.StaffUniqueId, model); var biography = await SaveStaffBiographyAsync(staffUsi, model); return(ToUserProfileModel(biography, new StaffProfileModel { Staff = profile.Staff, Profile = UserProfileModelToStaffProfile(profile.Staff.StaffUniqueId, newProfile) })); }
/// <summary> /// Update user signature details /// </summary> /// <param name="userProfile"></param> /// <returns></returns> public Response <UserProfileModel> UpdateUserSignatureDetails(UserProfileModel userProfile) { var response = new Response <UserProfileModel>() { ResultCode = -1, ResultMessage = "Error while saving the user's profile" }; userProfile.NewDigitalPassword = userProfile.NewDigitalPassword ?? string.Empty; userProfile.CurrentDigitalPassword = userProfile.CurrentDigitalPassword ?? string.Empty; var updatePassword = userProfile.CurrentDigitalPassword != string.Empty; var userProfileRepository = _unitOfWork.GetRepository <UserProfileModel>(); SqlParameter userIdParam = new SqlParameter("UserID", userProfile.UserID); SqlParameter updatePasswordParam = new SqlParameter("UpdatePassword", updatePassword); SqlParameter newPasswordParam = new SqlParameter("NewPassword", (userProfile.NewDigitalPassword == string.Empty) ? DBNull.Value : (object)userProfile.NewDigitalPassword); SqlParameter currentPasswordParam = new SqlParameter("CurrentPassword", userProfile.CurrentDigitalPassword); SqlParameter printSignatureParam = new SqlParameter("PrintSignature", userProfile.PrintSignature ?? string.Empty); SqlParameter modifiedOnParam = new SqlParameter("ModifiedOn", userProfile.ModifiedOn ?? DateTime.Now); List <SqlParameter> procParams = new List <SqlParameter>() { userIdParam, updatePasswordParam, newPasswordParam, currentPasswordParam, printSignatureParam, modifiedOnParam }; return(_unitOfWork.EnsureInTransaction(userProfileRepository.ExecuteNQStoredProc, "usp_UpdateUserSignatureDetails", procParams, forceRollback: userProfile.ForceRollback.GetValueOrDefault(false))); }
/// <summary> /// Save User password /// </summary> /// <param name="userPassowrd">user password model</param> /// <returns></returns> public Response <UserProfileModel> SaveUserPassword(UserProfileModel userProfile) { var response = new Response <UserProfileModel>() { ResultCode = -1, ResultMessage = "Error while saving the user's profile" }; userProfile.NewPassword = userProfile.NewPassword ?? string.Empty; userProfile.CurrentPassword = userProfile.CurrentPassword ?? string.Empty; var updatePassword = userProfile.IsTemporaryPassword || userProfile.CurrentPassword != string.Empty; var userProfileRepository = _unitOfWork.GetRepository <UserProfileModel>(); SqlParameter userIdParam = new SqlParameter("UserID", userProfile.UserID); SqlParameter updatePasswordParam = new SqlParameter("UpdatePassword", updatePassword); SqlParameter newPasswordParam = new SqlParameter("NewPassword", userProfile.NewPassword); SqlParameter currentPasswordParam = new SqlParameter("CurrentPassword", userProfile.CurrentPassword); SqlParameter modifiedOnParam = new SqlParameter("ModifiedOn", userProfile.ModifiedOn ?? DateTime.Now); List <SqlParameter> procParams = new List <SqlParameter>() { userIdParam, updatePasswordParam, newPasswordParam, currentPasswordParam, modifiedOnParam }; return(_unitOfWork.EnsureInTransaction(userProfileRepository.ExecuteNQStoredProc, "usp_SaveUserProfile", procParams, forceRollback: userProfile.ForceRollback.GetValueOrDefault(false))); }
public void UpdateProfileCorrectly() { const string address = "0x12345678901234567890"; const string addressEnd = "7890"; const string addressFormatted = "0x1234...567890"; UserProfileModel profileModel = new UserProfileModel() { name = "PraBian", userId = address, hasClaimedName = true }; UserProfile profile = UserProfile.GetOwnUserProfile(); profile.UpdateData(profileModel, false); for (int i = 0; i < controller.view.hideOnNameClaimed.Length; i++) { Assert.AreEqual(false, controller.view.hideOnNameClaimed[i].gameObject.activeSelf); } Assert.AreEqual(profileModel.name, controller.view.textName.text); profileModel.hasClaimedName = false; profile.UpdateData(profileModel, true); for (int i = 0; i < controller.view.hideOnNameClaimed.Length; i++) { Assert.AreEqual(true, controller.view.hideOnNameClaimed[i].gameObject.activeSelf); } Assert.AreEqual(profileModel.name, controller.view.textName.text); Assert.AreEqual($".{addressEnd}", controller.view.textPostfix.text); Assert.AreEqual(addressFormatted, controller.view.textAddress.text); }
public async Task <ActionResult> Index(UserProfileModel userProfile) { string id_token = GenerateJWTClientToken(userProfile); string redirect_uri = this.Request.Query["redirect_uri"]; string state = this.Request.Query["state"]; string rid = this.Request.Query["rid"]; IdentityEntity identityEntity = await GetIdentityEntity(rid); // Check the request if (!isValidRequest(identityEntity, redirect_uri)) { return(View("Error")); } // Update the account AzureADGraphClient azureADGraphClient = new AzureADGraphClient(this.AppSettings.Tenant, this.AppSettings.ClientId, this.AppSettings.ClientSecret); // Create the user using Graph API await azureADGraphClient.UpdateAccount(identityEntity.userId, userProfile.City); // Wait until user is updated //await Task.Delay(2500); // Delete the entity await DeleteIdentityEntity(identityEntity); string redirectUri = $"{redirect_uri}?id_token={id_token}&state={state}"; return(Redirect(redirectUri)); }
/// <summary> /// Set profile data. /// </summary> /// <param name="services">Platfrom services.</param> /// <param name="profile">Profile model.</param> public static void SetProfileData(IPlatformServices services, UserProfileModel profile) { if (profile == null) { return; } IsProfileLoaded = true; GroupId = profile.GroupId; GroupName = profile.GroupName; Avatar = profile.Avatar; Name = profile.Name; services.Preferences.Avatar = Avatar; services.Preferences.GroupName = GroupName; switch (profile.UserType) { case _professorType: UserType = UserTypeEnum.Professor; break; case _studentType: UserType = UserTypeEnum.Student; break; } }
public ActionResult AccountDetail(UserProfileModel model) { using (var scope = new TransactionScope()) { if (!Equals(model.Password, model.ConfirmPassword)) { ModelState.AddModelError("ConfirmPassword", "Xác nhận mật khẩu không chính xác"); return(View(model)); } var userProfile = _service.GetActiveUserProfileById(model.Id); userProfile.full_name = model.FullName; _service.SaveUserProfile(userProfile); if (Equals(model.Password, null)) { var userAccount = _service.GetUserAccountByUserProfileId(userProfile.user_profile_id); userAccount.password = Encrypt.EncodePassword(model.Password); _service.SaveUserAccount(userAccount); } scope.Complete(); } return(RedirectToAction("Account")); }
public async Task Init() { await TestCleaner.CleanDatabase(); var numTestRows = 20; IDataGateway dataGateway = new SQLServerGateway(); IConnectionStringData connectionString = new ConnectionStringData(); IUserAccountRepository userAccountRepository = new UserAccountRepository(dataGateway, connectionString); IUserProfileRepository userProfileRepository = new UserProfileRepository(dataGateway, connectionString); for (int i = 1; i <= numTestRows; ++i) { UserAccountModel userAccountModel = new UserAccountModel(); userAccountModel.Id = i; userAccountModel.Username = "******" + i; userAccountModel.Password = "******" + i; userAccountModel.Salt = "TestSalt" + i; userAccountModel.EmailAddress = "TestEmailAddress" + i; userAccountModel.AccountType = "TestAccountType" + i; userAccountModel.AccountStatus = "TestAccountStatus" + i; userAccountModel.CreationDate = DateTimeOffset.UtcNow; userAccountModel.UpdationDate = DateTimeOffset.UtcNow; await userAccountRepository.CreateAccount(userAccountModel); UserProfileModel userProfileModel = new UserProfileModel(); userProfileModel.Id = i; userProfileModel.FirstName = "TestFirstName" + i; userProfileModel.Surname = "TestSurname" + i; userProfileModel.DateOfBirth = DateTimeOffset.UtcNow; userProfileModel.UserAccountId = userAccountModel.Id; await userProfileRepository.CreateUserProfile(userProfileModel); } }
public ActionResult UserProfile(UserProfileModel model) { var userinfo = new UserInfoModel { UserName = UserInfo.username, NickName = model.NickName, Signature = model.Signature, Intro = model.Intro, Gender = model.Gender, Birth = model.Birth, Location = model.Location, Website = model.Website, Qq = model.Qq, Sina = model.Sina, Facebook = model.Facebook, Twitter = model.Twitter, Medals = model.Medals, Phone = model.Phone, Email = model.Email, IsSendEmail = model.IsSendEmail }; MyService.UpdateUserProfile(userinfo); return(Content("", "text/html;charset=UTF-8")); }
protected override IEnumerator SetUp() { yield return(base.SetUp()); UserProfile ownProfile = UserProfile.GetOwnUserProfile(); CommonScriptableObjects.rendererState.Set(true); var ownProfileModel = new UserProfileModel(); ownProfileModel.userId = "my-user-id"; ownProfileModel.name = "NO_USER"; ownProfile.UpdateData(ownProfileModel, false); userProfileGO = new GameObject(); userProfile = userProfileGO.AddComponent <UserProfileController>().ownUserProfile; controller = new TaskbarHUDController(); controller.Initialize(null, chatController, null); view = controller.view; Assert.IsTrue(view != null, "Taskbar view is null?"); Assert.IsTrue(view.moreButton.gameObject.activeSelf, "More button is not actived?"); Assert.IsTrue(CommonScriptableObjects.isTaskbarHUDInitialized, "Taskbar controller is not initialized?"); }
public async Task <DataProviderVoidModel> UpdateUser(UserProfileModel oldProfile, UserProfileModel newProfile) { var queryIdentifier = Guid.NewGuid().ToString(); var query = new Query(queryIdentifier, "UpdateUser"); if ((newProfile.LastName ?? "") != (oldProfile.LastName ?? "")) { query.Parameters.Add(new QueryParameter("in", "LastName", newProfile.LastName ?? "", SqlDbType.NVarChar)); } if ((newProfile.FirstName ?? "") != (oldProfile.FirstName ?? "")) { query.Parameters.Add(new QueryParameter("in", "FirstName", newProfile.FirstName ?? "", SqlDbType.NVarChar)); } if ((newProfile.SecondName ?? "") != (oldProfile.SecondName ?? "")) { query.Parameters.Add(new QueryParameter("in", "SecondName", newProfile.SecondName ?? "", SqlDbType.NVarChar)); } if (oldProfile.BirthDate != newProfile.BirthDate) { query.Parameters.Add(new QueryParameter("in", "BirthDate", newProfile.BirthDate?.ToString() ?? String.Empty, SqlDbType.DateTime)); } if ((newProfile.UserName ?? "") != (oldProfile.UserName ?? "")) { query.Parameters.Add(new QueryParameter("in", "UserName", newProfile.UserName, SqlDbType.NVarChar)); } var result = await _sessionQueryExecutor.Execute(new List <Query> { query }).ConfigureAwait(false); return(new DataProviderVoidModel(result.ResultMessage)); }
public void Create(UserProfileModel model) { try { _unitOfWork.BeginTransaction(); if (!String.IsNullOrEmpty(model.EmailAddress)) { if (_repository.EmailExists(model)) { throw new DuplicateNameException("A user with that e-mail address already exists!"); } } var entity = Mapper.Map <UserProfileModel, UserProfile>(model); entity.DateCreated = DateTime.Now; _repository.Insert(entity); model.Id = entity.Id; _unitOfWork.Commit(); } catch (DuplicateNameException ec) { throw new Exception("An error has occured " + ec.Message); } catch (Exception ec) { _unitOfWork.Rollback(); throw new Exception("An error has occured " + ec.Message); } }
public async Task <ActionResult> MyProfile() { UserProfileModel model = null; try { ProfileDTO dto = await accountService.GetProfile(User.Identity.GetUserId()); if (dto != null) { model = new UserProfileModel { Id = dto.Id, Age = dto.Age, FirstName = dto.FirstName, LastName = dto.LastName, Profession = dto.Profession }; } else { model = new UserProfileModel(); } } catch (Exception) { return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError)); } return(View("Profile", model)); }
public void UpdateProfile(UserProfileModel model) { MySqlCommand comm = new MySqlCommand("", db.conexao); comm.CommandText = "UPDATE usuario set nome = @nome, telefone = @telefone WHERE id_usuario = @id_usuario"; comm.Parameters.AddWithValue("@nome", model.Name); comm.Parameters.AddWithValue("@telefone", model.Phone); comm.Parameters.AddWithValue("@id_usuario", model.Id); try { db.conexao.Open(); comm.ExecuteNonQuery(); } catch (Exception e) { } finally { db.conexao.Close(); } }
public void AddUserProfileToCatalog(UserProfileModel model) { var userProfile = ScriptableObject.CreateInstance <UserProfile>(); userProfile.UpdateData(model); userProfilesCatalog.Add(model.userId, userProfile); }
public ActionResult Create(UserProfileModel model) { if (ModelState.IsValid) { webpages_Membership member = new webpages_Membership(); UserProfile user = new UserProfile(); UserModel userModel = new UserModel(); userModel.FullName = model.FullName; userModel.Group_Id = model.Group_Id; userModel.Email = model.Email; bool checkSave = false; user.UserName = model.UserName; user.FullName = model.FullName; user.Email = model.Email; WebSecurity.CreateUserAndAccount(model.UserName, model.Password, userModel, true); member = membershipService.webpages_MembershipResponsitory.Single(WebSecurity.GetUserId(model.UserName)); if (member != null) { member.IsConfirmed = true; checkSave = membershipService.webpages_MembershipResponsitory.Update(member); } TempData["MessageStatus"] = checkSave; TempData["Message"] = $"thêm mới tài khoản {(checkSave ? "" : "không")} thành công"; return(RedirectToAction("Management")); } return(View(model)); }
private async Task ShowFriend(UserProfileModel arg) { await ShowViewModel <ProfileViewModel, ProfileUserModel>(new ProfileUserModel { UserId = arg.Id }); }
public ActionResult ResetPass(int id) { UserProfileModel model = new UserProfileModel(); model.Id = id; return(PartialView(model)); }
public async Task UserProfile_With_User(KnownChains apiName, string user) { // Arrange var request = new UserProfileModel(user) { Login = user }; // Act var response = await Api[apiName].GetUserProfile(request, CancellationToken.None); // Assert AssertResult(response); Assert.That(response.Result.PostingRewards, Is.Not.Null); Assert.That(response.Result.CurationRewards, Is.Not.Null); Assert.That(response.Result.LastAccountUpdate, Is.Not.Null); Assert.That(response.Result.LastVoteTime, Is.Not.Null); Assert.That(response.Result.Reputation, Is.Not.Null); Assert.That(response.Result.PostCount, Is.Not.Null); Assert.That(response.Result.CommentCount, Is.Not.Null); Assert.That(response.Result.FollowersCount, Is.Not.Null); Assert.That(response.Result.FollowingCount, Is.Not.Null); Assert.That(response.Result.Username, Is.Not.Empty); Assert.That(response.Result.CurrentUser, Is.Not.Null); Assert.That(response.Result.ProfileImage, Is.Not.Null); Assert.That(response.Result.HasFollowed, Is.Not.Null); Assert.That(response.Result.EstimatedBalance, Is.Not.Null); Assert.That(response.Result.Created, Is.Not.Null); Assert.That(response.Result.Name, Is.Not.Null); Assert.That(response.Result.About, Is.Not.Null); Assert.That(response.Result.Location, Is.Not.Null); Assert.That(response.Result.Website, Is.Not.Null); }
public ActionResult Post(Book book) { ActionResult response = BadRequest("invalid data"); Transaction transaction = _patientService.Book(book); if (transaction != null) { UserProfileModel userProfile = _userService.GetUserProfile(book.patientId); Data data = new Data { Id = book.patientId, Image = userProfile.Image, Lat = book.location.lat, Long = book.location.longt, Name = userProfile.Fname + " " + userProfile.Lname, Tans_Id = transaction.Id, body = "waiting to approve your request", title = "You have a request" }; _notificationService.SendNotification(_userService.GetTokens(book.doctorId), data); _notificationService.AddNotification(new Notification { Date = DateTime.Now, Message = "waiting to approve your request", Read = true, Tans_Id = transaction.Id, UserFrom_Id = book.patientId, UserTo_Id = book.doctorId }); response = Ok(); } return(response); }
public async Task <IActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid) { UserProfileModel user = new UserProfileModel { Email = model.Email, UserName = model.Email }; var result = await _userManager.CreateAsync(user, model.Password); if (result.Succeeded) { await _signInManager.SignInAsync(user, false); return(RedirectToAction("Index", "Home")); } else { foreach (var error in result.Errors) { ModelState.AddModelError(string.Empty, error.Description); } } } return(View(model)); }
public String[] SaveClimberApps(UserProfileModel user, long compId, IEnumerable <ClimberApplication> models) { if (models == null || models != null && models.Count(m => m.Confirmed) < 1) { return new String[] { "Нет ни одной подтвержденной заявки" } } ; var comp = db.Competitions.Find(compId); if (comp == null) { return new String[] { "Не удалось найти сорвенования для заявки" } } ; if (!comp.AllowedToAdd(user)) { return new String[] { "У вас нет прав для подачи заявок" } } ; var errors = (from item in models.Where(m => m.Confirmed) from error in SaveClimberApp(user, compId, item, false) select error).ToArray(); if (errors.Length < 1) { db.SaveChanges(); } return(errors); }
public async Task <ActionResult> UpdateProfile(UserProfileModel model) { if (model == null) { return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError)); } if (ModelState.IsValid) { try { ProfileDTO dto = new ProfileDTO { Id = model.Id, FirstName = model.FirstName, LastName = model.LastName, Profession = model.Profession, Age = model.Age }; await accountService.UpdateProfile(dto); return(new HttpStatusCodeResult(HttpStatusCode.OK)); } catch (Exception) { return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError)); } } else { HttpContext.Response.StatusCode = 400; return(View("Profile", model)); } }
public UserProfileUpdated(Guid operationId, UserProfileModel userProfile) { Assert.NotNull("userProfile", userProfile); OperationId = operationId; Code = "USER_PROFILE_UPDATED"; Description = string.Format("User profile [{0}] changed.", userProfile.UserId); Data = null; }
public UserProfileModel GetUserModel(User user , List<History> history) { UserProfileModel upm = new UserProfileModel { Id = user.Id, Name = user.Name, Surname = user.Surname, Middlename = user.MiddleName, Phone = user.Phone, Login = user.Login, History = history }; return upm; }
public virtual DataResultUserProfile Get(IUserRequestModel userRequest) { if (!_objCacheManager.Contains(this.CacheManager_GetKey(userRequest))) { ProfileBase p = ProfileBase.Create(userRequest.UserFormsIdentity.Name, userRequest.UserFormsIdentity.IsAuthenticated); UserProfileModel userProfile = new UserProfileModel(p); DataResultUserProfile result = new DataResultUserProfile() { IsValid = true, Data = userProfile, MessageType = DataResultMessageType.Success }; _objCacheManager.Add(this.CacheManager_GetKey(userRequest), result, _objCachePolicy); } return (DataResultUserProfile)_objCacheManager.Get(this.CacheManager_GetKey(userRequest)); }
public ActionResult Index(IEnumerable<EventModel> events = null) { if (events == null) events = getEventService().GetAllEvents().Reverse().Take(10); UserProfileModel profile = getAccountService().GetUserProfileByUsername(User.Identity.Name); NotificationsShortList notifications = profile != null ? new NotificationsShortList { UnreadMessages = getEventService().GetMessages(new GetMessagesModel { GetUnreadOnly = true, UserProfileID = profile.UserProfileId }).Count(), FriendRequests = getAccountService().GetFriendRequests(new GetFriendRequestsModel { UserProfileId = profile.UserProfileId }).Count() } : null; if (profile == null) profile = new UserProfileModel { Avatar = "", FirstName = "", LastName = "" }; IndexSidebarViewModel sidebar = new IndexSidebarViewModel { AvatarUrl = profile.Avatar, Name = profile.FirstName + " " + profile.LastName, Notifications = notifications, Username = User.Identity.Name }; return View(new IndexViewModel { DisplayName = sidebar.Name, Events = events, Sidebar = sidebar }); }
public virtual DataResultUserProfile Update(UserProfileModel userProfile, IUserRequestModel userRequest) { if (_objCacheManager.Contains(this.CacheManager_GetKey(userRequest))) { _objCacheManager.Remove(this.CacheManager_GetKey(userRequest)); } ProfileBase p = ProfileBase.Create(userRequest.UserFormsIdentity.Name); userProfile.SetProfileBasePropertyValues(ref p); p.Save(); DataResultUserProfile result = new DataResultUserProfile() { IsValid = true, Data = userProfile, MessageType = DataResultMessageType.Success }; return result; }
public UserProfileModel BuildOneUser(string login) { var userProfile = new UserProfileModel(); if (string.IsNullOrEmpty(login)) { if (WebSecurity.IsAuthenticated) { userProfile = GetOneUser(WebSecurity.CurrentUserName); } } else { userProfile = GetOneUser(login); } return userProfile; }
public virtual DataResultUserProfile Create(string userName, IUserRequestModel userRequest) { UserProfileModel userProfile = new UserProfileModel(); userProfile.UserName = userName; userProfile.Culture = userRequest.UserProfile.Culture; userProfile.Theme = userRequest.UserProfile.Theme; ProfileBase p = ProfileBase.Create(userName); p.SetPropertyValue(baseModel.GetInfo(() => userProfile.Culture).Name, userProfile.Culture.Name.ToString()); p.SetPropertyValue(baseModel.GetInfo(() => userProfile.Theme).Name, userProfile.Theme.Value.ToString()); p.Save(); DataResultUserProfile result = new DataResultUserProfile() { IsValid = true, Data = userProfile, MessageType = $customNamespace$.Models.Enumerations.DataResultMessageType.Success }; return result; }
public DataResultUserProfile Update(UserProfileModel userProfile) { DataResultUserProfile result = this._dal.Update(userProfile, this.UserRequest); result.Message = Resources.UserAdministration.UserAdminTexts.UserSaved; return result; }
public ActionResult ViewProfile(string userName) { if(string.IsNullOrEmpty(userName)) userName = HttpContext.User.Identity.Name; if(string.IsNullOrEmpty(userName)) return View(); UserRepository repo = new UserRepository(); UserModel user = repo.GetByUsernameWithPhotos(userName); UserProfileModel profile = null; if (user == null) { ViewBag.ErrorMessage = string.Format("Can't find user {0}", userName); return View(profile); } DateTime? startTime = user.DateOfBirth; string age = ""; if (startTime == null) age = "Unavailable"; else age = "" + Helpers.GetAge(startTime ?? DateTime.Today); profile = new UserProfileModel() { Name = user.Login, About = user.About, Age = age, Albums = new List<AlbumProfileModel>() }; string start,end; foreach (AlbumModel album in user.Albums) { Helpers.AlbumDateRange(album, out start , out end); AlbumProfileModel profileAlbum = new AlbumProfileModel() { Id = album.Id, Name = album.Name, Thumbnails = Helpers.AlbumThumbnails(album), StartDate = start, EndDate = end, Views = album.Views }; profile.Albums.Add(profileAlbum); } profile.Albums.Sort(delegate(AlbumProfileModel a, AlbumProfileModel b) { int aa=a.Id??0; int bb=b.Id??0; return aa.CompareTo(bb); }); return View(profile); }
public static UserProfileModel UserProfileToUserProfileModel(UserProfile userProfile) { if (userProfile != null) { UserProfileModel userProfileModel = new UserProfileModel(); userProfileModel.UserProfileId = userProfile.UserProfileId; userProfileModel.FirstName = userProfile.FirstName; userProfileModel.LastName = userProfile.LastName; userProfileModel.IsFemale = userProfile.IsFemale; userProfileModel.Description = userProfile.Description; userProfileModel.AcceptedFriendships = userProfile.AcceptedFriendships; userProfileModel.RequestedFriendships = userProfile.RequestedFriendships; userProfileModel.Birthdate = userProfile.Birthdate; userProfileModel.Comments = userProfile.Comments; userProfileModel.Reputation = userProfile.Reputation; userProfileModel.Avatar = userProfile.Avatar; userProfileModel.PendingFriendRequests = userProfile.PendingFriendRequests; userProfileModel.RequestedFriendRequests = userProfile.RequestedFriendRequests; return userProfileModel; } else { return null; } }
public DataResultUserProfile Update(UserProfileModel userProfile) { return this._bl.Update(userProfile); }
private IndexViewModel generateIndexViewModel(IEnumerable<EventModel> events) { UserProfileModel profile = accountServices.GetUserProfileByUsername(User.Identity.Name); NotificationsShortList notifications = profile != null ? new NotificationsShortList { UnreadMessages = eventServices.GetMessages(new GetMessagesModel { GetUnreadOnly = true, UserProfileID = profile.UserProfileId }).Count(), FriendRequests = accountServices.GetFriendRequests(new GetFriendRequestsModel { UserProfileId = profile.UserProfileId }).Count() } : null; if (profile == null) profile = new UserProfileModel { Avatar = "", FirstName = "", LastName = "" }; IndexSidebarViewModel sidebar = new IndexSidebarViewModel { AvatarUrl = profile.Avatar, Name = profile.FirstName + " " + profile.LastName, Notifications = notifications, Username = User.Identity.Name }; return (new IndexViewModel { DisplayName = sidebar.Name, Events = events, Sidebar = sidebar }); }
public bool UpdateUserProfile(UserProfileModel userProfileModel) { UserProfile userProfile = db.UserProfiles.Where(u => u.UserProfileId == userProfileModel.UserProfileId).FirstOrDefault(); if (userProfile != null) { userProfile.FirstName = userProfileModel.FirstName; userProfile.LastName = userProfileModel.LastName; userProfile.Birthdate = userProfileModel.Birthdate; userProfile.IsFemale = userProfileModel.IsFemale; userProfile.Description = userProfileModel.Description; userProfile.Reputation = userProfileModel.Reputation; userProfile.Avatar = userProfileModel.Avatar; db.SaveChanges(); return true; } else { return false; } }
public void AddOrUpdateAttachment(UserProfileModel model, HttpPostedFileBase theFile) { try { byte[] data; using (Stream inputStream = theFile.InputStream) { MemoryStream memoryStream = inputStream as MemoryStream; // MemoryStream memoryStream = new MemoryStream(); if (memoryStream == null) { memoryStream = new MemoryStream(); inputStream.CopyTo(memoryStream); } data = memoryStream.ToArray(); } Attachment obj = new Attachment(); obj.UserId = 1033; obj.Buffer = data; _repository.AddAttachment(obj); } catch (Exception ex) { string msg = ex.Message; } }