Example #1
0
        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());
            }
        }
Example #2
0
        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());
            }
        }
 public DTO.AccountMng.User DB2DTO_User(AccountMng_UserProfile_View dbItem)
 {
     return(AutoMapper.Mapper.Map <AccountMng_UserProfile_View, DTO.AccountMng.User>(dbItem));
 }