public DTO.AccountMng.User GetUserInformation(int userId, out Library.DTO.Notification notification) { notification = new Library.DTO.Notification() { Type = Library.DTO.NotificationType.Success }; try { using (AccountMngEntities context = CreateContext()) { UserProfile dbUser = context.UserProfile.FirstOrDefault(o => o.UserId == userId); dbUser.LastLoginDate = DateTime.Now; context.SaveChanges(); AccountMng_UserProfile_View result = context.AccountMng_UserProfile_View .Include("AccountMng_UserPermission_View") .Include("AccountMng_Branch_View") .FirstOrDefault(o => o.UserId == userId); return(converter.DB2DTO_User(result)); } } catch (Exception ex) { notification = new Library.DTO.Notification() { Message = ex.Message }; return(new DTO.AccountMng.User()); } }
public void UpdateLastPasswordChange(string aspNetUserId) { try { using (AccountMngEntities context = CreateContext()) { UserProfile dbUser = context.UserProfile.FirstOrDefault(o => o.AspNetUsersId == aspNetUserId); if (dbUser != null) { dbUser.LastPasswordChanged = DateTime.Now; dbUser.IsForcedToChangePassword = false; context.SaveChanges(); } } } catch { } }
public DTO.AccountMng.User GetUserInformationLight(int userId, out Library.DTO.Notification notification) { notification = new Library.DTO.Notification() { Type = Library.DTO.NotificationType.Success }; try { using (AccountMngEntities context = CreateContext()) { UserProfile dbUser = context.UserProfile.FirstOrDefault(o => o.UserId == userId); dbUser.LastLoginDate = DateTime.Now; context.SaveChanges(); AccountMng_UserProfile_View result = context.AccountMng_UserProfile_View.FirstOrDefault(o => o.UserId == userId); if (result == null) { throw new Exception("User info not found!"); } return(new DTO.AccountMng.User() { FullName = result.FullName, Email = result.Email, UserName = result.UserName, PersonalPhoto_DisplayUrl = !string.IsNullOrEmpty(result.PersonalPhoto_DisplayUrl) ? FrameworkSetting.Setting.MediaThumbnailUrl + result.PersonalPhoto_DisplayUrl : string.Empty, PhoneNumber = result.PhoneNumber }); } } catch (Exception ex) { notification = new Library.DTO.Notification() { Message = ex.Message }; return(new DTO.AccountMng.User()); } }