예제 #1
0
        private List <string> CheckDetailsMethod(Type controller)
        {
            string            pattern    = string.Empty;
            OperationResultVo ids        = null;
            List <string>     methodList = new List <string>();

            if (controller.Name.Equals("ProfileController"))
            {
                pattern = "profile/{0}";
                ids     = ProfileAppService.GetAllIds(Guid.Empty);
            }
            else if (controller.Name.Equals("GameController"))
            {
                pattern = "game/{0}";
                ids     = GameAppService.GetAllIds(Guid.Empty);
            }
            else if (controller.Name.Equals("ContentController"))
            {
                pattern = "content/{0}";
                ids     = ContentAppService.GetAllIds(Guid.Empty);
            }

            if (ids != null && !string.IsNullOrWhiteSpace(pattern))
            {
                List <string> urls = GetDetailUrls(controller, ids, pattern);

                methodList.AddRange(urls);
            }

            return(methodList);
        }
예제 #2
0
        public async Task <IActionResult> Save(UserContentViewModel vm)
        {
            try
            {
                bool isNew = vm.Id == Guid.Empty;

                ProfileViewModel profile = await ProfileAppService.GetByUserId(CurrentUserId, ProfileType.Personal);

                SetAuthorDetails(vm);

                OperationResultVo <Guid> saveResult = userContentAppService.Save(CurrentUserId, vm);

                if (!saveResult.Success)
                {
                    return(Json(saveResult));
                }
                else
                {
                    NotifyFollowers(profile, vm.GameId, vm.Id);

                    string url = Url.Action("Index", "Home", new { area = string.Empty, id = vm.Id, pointsEarned = saveResult.PointsEarned });

                    if (isNew && EnvName.Equals(ConstantHelper.ProductionEnvironmentName))
                    {
                        await NotificationSender.SendTeamNotificationAsync("New complex post!");
                    }

                    return(Json(new OperationResultRedirectVo(url)));
                }
            }
            catch (Exception ex)
            {
                return(Json(new OperationResultVo(ex.Message)));
            }
        }
예제 #3
0
        public async Task <IActionResult> SimplePost(string text, string images, IEnumerable <PollOptionViewModel> pollOptions, SupportedLanguage?language, Guid?gameId)
        {
            UserContentViewModel vm = new UserContentViewModel
            {
                Language = language ?? SupportedLanguage.English,
                Content  = text,
                Poll     = new PollViewModel
                {
                    PollOptions = pollOptions.ToList()
                },
                GameId = gameId
            };

            ProfileViewModel profile = await ProfileAppService.GetByUserId(CurrentUserId, ProfileType.Personal);

            SetAuthorDetails(vm);

            SetContentImages(vm, images);

            OperationResultVo <Guid> result = userContentAppService.Save(CurrentUserId, vm);

            NotifyFollowers(profile, vm.GameId, vm.Id);

            if (EnvName.Equals(ConstantHelper.ProductionEnvironmentName))
            {
                await NotificationSender.SendTeamNotificationAsync("New simple post!");
            }

            return(Json(result));
        }
예제 #4
0
 public CommonQueryAppService(RoleManager roleManager, IUserAppService userAppServce,
                              IRepository <SysStatus> sysStatusRepository,
                              IRepository <SysRef, int> lookup_sysRefRepository,
                              ProfileAppService profileAppService,
                              IRepository <TeamMember> teamMemberRepository,
                              IRepository <UserRole, long> userRoleRepository,
                              IRepository <ParamSetting> paramSettingRepository,
                              IRepository <SysRef> sysRefRepository,
                              IRepository <ReferenceType, int> lookup_referenceTypeRepository,
                              IRepository <ApprovalRequest> approvalRequestRepository,
                              IRepository <SysStatus, int> lookup_sysStatusRepository,
                              IRepository <User, long> lookup_userRepository,
                              IRepository <Team, int> lookup_teamRepository
                              )
 {
     _roleManager                    = roleManager;
     _userAppServce                  = userAppServce;
     _lookup_userRepository          = lookup_userRepository;
     _SysStatusRepository            = sysStatusRepository;
     _lookup_sysStatusRepository     = lookup_sysStatusRepository;
     _lookup_sysRefRepository        = lookup_sysRefRepository;
     _profileAppService              = profileAppService;
     _teamMemberRepository           = teamMemberRepository;
     _userRoleRepository             = userRoleRepository;
     _paramSettingRepository         = paramSettingRepository;
     _sysRefRepository               = sysRefRepository;
     _lookup_referenceTypeRepository = lookup_referenceTypeRepository;
     _approvalRequestRepository      = approvalRequestRepository;
     _lookup_teamRepository          = lookup_teamRepository;
 }
예제 #5
0
        protected async Task ChangePasswordAsync()
        {
            if (string.IsNullOrWhiteSpace(ChangePasswordModel.CurrentPassword))
            {
                return;
            }

            if (ChangePasswordModel.NewPassword != ChangePasswordModel.NewPasswordConfirm)
            {
                await UiMessageService.WarnAsync(L["NewPasswordConfirmFailed"]);

                return;
            }

            if (!await UiMessageService.ConfirmAsync(UiLocalizer["AreYouSure"]))
            {
                return;
            }

            await ProfileAppService.ChangePasswordAsync(new ChangePasswordInput
            {
                CurrentPassword = ChangePasswordModel.CurrentPassword,
                NewPassword     = ChangePasswordModel.NewPassword
            });

            await UiMessageService.SuccessAsync(L["PasswordChanged"]);
        }
예제 #6
0
        public async Task <IActionResult> FixUserInconcistencies()
        {
            List <string> messages = new List <string>();
            OperationResultListVo <string> result = new OperationResultListVo <string>(messages)
            {
                Message = "Update Handlers Task"
            };

            try
            {
                IQueryable <ApplicationUser> allUsers = await GetUsersAsync();

                OperationResultListVo <ProfileViewModel> profileResult = ProfileAppService.GetAll(CurrentUserId, true);

                if (!profileResult.Success)
                {
                    return(View("TaskResult", profileResult));
                }

                IQueryable <ApplicationUser> usersWithoutDate = allUsers.Where(x => x.CreateDate == DateTime.MinValue);
                foreach (ApplicationUser user in usersWithoutDate)
                {
                    ProfileViewModel profile = profileResult.Value.FirstOrDefault(x => x.UserId.ToString().Equals(user.Id));
                    if (profile != null)
                    {
                        user.CreateDate = profile.CreateDate;
                        await UserManager.UpdateAsync(user);
                    }
                }

                foreach (ProfileViewModel profile in profileResult.Value)
                {
                    ApplicationUser user = allUsers.FirstOrDefault(x => x.Id.Equals(profile.UserId.ToString()));
                    if (user == null)
                    {
                        messages.Add($"ERROR: user for {profile.Handler} ({profile.UserId}) NOT FOUND");
                    }
                    else
                    {
                        string handler = user.UserName.ToLower();
                        if (string.IsNullOrWhiteSpace(profile.Handler) || !profile.Handler.Equals(handler))
                        {
                            profile.Handler = handler;
                            OperationResultVo <Guid> saveResult = ProfileAppService.Save(CurrentUserId, profile);
                            messages.Add($"SUCCESS: {profile.Name} handler updated to \"{handler}\"");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                result.Success = false;
                messages.Add("ERROR: " + ex.Message);
            }

            result.Value = messages.OrderBy(x => x);

            return(View("TaskResult", result));
        }
예제 #7
0
        protected async Task UpdatePersonalInfoAsync()
        {
            await ProfileAppService.UpdateAsync(
                ObjectMapper.Map <PersonalInfoModel, UpdateProfileDto>(PersonalInfoModel)
                );

            await UiMessageService.SuccessAsync(L["PersonalSettingsSaved"]);
        }
예제 #8
0
 public ApprovalRequestsAppService(IRepository <ApprovalRequest> approvalRequestRepository, IApprovalRequestsExcelExporter approvalRequestsExcelExporter,
                                   IRepository <SysRef, int> lookup_sysRefRepository, IRepository <SysStatus, int> lookup_sysStatusRepository, IRepository <User, long> lookup_userRepository,
                                   ProfileAppService profileAppService)
 {
     _approvalRequestRepository     = approvalRequestRepository;
     _approvalRequestsExcelExporter = approvalRequestsExcelExporter;
     _lookup_sysRefRepository       = lookup_sysRefRepository;
     _lookup_sysStatusRepository    = lookup_sysStatusRepository;
     _lookup_userRepository         = lookup_userRepository;
     _profileAppService             = profileAppService;
 }
예제 #9
0
        protected async Task GetUserInformations()
        {
            var user = await ProfileAppService.GetAsync();

            ChangePasswordModel = new ChangePasswordModel
            {
                HideOldPasswordInput = !user.HasPassword
            };

            PersonalInfoModel = ObjectMapper.Map <ProfileDto, PersonalInfoModel>(user);
        }
예제 #10
0
        protected async Task UpdatePersonalInfoAsync()
        {
            if (!await UiMessageService.ConfirmAsync(UiLocalizer["AreYouSure"]))
            {
                return;
            }

            await ProfileAppService.UpdateAsync(
                ObjectMapper.Map <PersonalInfoModel, UpdateProfileDto>(PersonalInfoModel)
                );

            await UiMessageService.SuccessAsync(L["PersonalSettingsSaved"]);
        }
예제 #11
0
 public TeamMembersAppService(IRepository <TeamMember> teamMemberRepository, ITeamMembersExcelExporter teamMembersExcelExporter,
                              IRepository <Team, int> lookup_teamRepository, IRepository <User, long> lookup_userRepository,
                              IRepository <SysRef, int> lookup_sysRefRepository, IRepository <SysStatus, int> lookup_sysStatusRepository,
                              ProfileAppService profileAppService
                              )
 {
     _teamMemberRepository       = teamMemberRepository;
     _teamMembersExcelExporter   = teamMembersExcelExporter;
     _lookup_teamRepository      = lookup_teamRepository;
     _lookup_userRepository      = lookup_userRepository;
     _lookup_sysRefRepository    = lookup_sysRefRepository;
     _lookup_sysStatusRepository = lookup_sysStatusRepository;
     _profileAppService          = profileAppService;
 }
예제 #12
0
        private async Task SetAuthorDetails(GameViewModel vm)
        {
            if (vm.Id == Guid.Empty || vm.UserId == Guid.Empty || vm.UserId == CurrentUserId)
            {
                vm.UserId = CurrentUserId;
                ProfileViewModel profile = await ProfileAppService.GetByUserId(CurrentUserId, ProfileType.Personal);

                if (profile != null)
                {
                    vm.AuthorName    = profile.Name;
                    vm.AuthorPicture = profile.ProfileImageUrl;
                }
            }
        }
예제 #13
0
        public async Task <IActionResult> AnalyseUser(Guid userId)
        {
            AnalyseUserViewModel model = new AnalyseUserViewModel();

            ApplicationUser user = await UserManager.FindByIdAsync(userId.ToString());

            ProfileViewModel profile = await ProfileAppService.GetByUserId(userId, ProfileType.Personal);

            var roles = await UserManager.GetRolesAsync(user);

            user.Roles = roles.ToList();

            model.User    = user;
            model.Profile = profile;

            return(View(model));
        }
 public UserAppService(
     RoleManager roleManager,
     IUserEmailer userEmailer,
     IUserListExcelExporter userListExcelExporter,
     INotificationSubscriptionManager notificationSubscriptionManager,
     IAppNotifier appNotifier,
     IRepository <RolePermissionSetting, long> rolePermissionRepository,
     IRepository <UserPermissionSetting, long> userPermissionRepository,
     IRepository <UserRole, long> userRoleRepository,
     IRepository <Role> roleRepository,
     IUserPolicy userPolicy,
     IEnumerable <IPasswordValidator <User> > passwordValidators,
     IPasswordHasher <User> passwordHasher,
     IRepository <OrganizationUnit, long> organizationUnitRepository,
     IRoleManagementConfig roleManagementConfig,
     UserManager userManager,
     IRepository <UserOrganizationUnit, long> userOrganizationUnitRepository,
     IRepository <OrganizationUnitRole, long> organizationUnitRoleRepository,
     ProfileAppService profileAppService,
     TeamMembersAppService teamMembersAppService,
     IRepository <TeamMember> teamMemberRepository)
 {
     _roleManager                     = roleManager;
     _userEmailer                     = userEmailer;
     _userListExcelExporter           = userListExcelExporter;
     _notificationSubscriptionManager = notificationSubscriptionManager;
     _appNotifier                     = appNotifier;
     _rolePermissionRepository        = rolePermissionRepository;
     _userPermissionRepository        = userPermissionRepository;
     _userRoleRepository              = userRoleRepository;
     _userPolicy                     = userPolicy;
     _passwordValidators             = passwordValidators;
     _passwordHasher                 = passwordHasher;
     _organizationUnitRepository     = organizationUnitRepository;
     _roleManagementConfig           = roleManagementConfig;
     _userManager                    = userManager;
     _userOrganizationUnitRepository = userOrganizationUnitRepository;
     _organizationUnitRoleRepository = organizationUnitRoleRepository;
     _profileAppService              = profileAppService;
     _teamMembersAppService          = teamMembersAppService;
     _roleRepository                 = roleRepository;
     _teamMemberRepository           = teamMemberRepository;
     AppUrlService                   = NullAppUrlService.Instance;
 }
예제 #15
0
        protected void SetProfileOnSession(Guid userId, string userName)
        {
            string sessionUserName = GetSessionValue(SessionValues.Username);

            if (sessionUserName != null && !sessionUserName.Equals(userName))
            {
                SetSessionValue(SessionValues.Username, userName);
            }

            string sessionFullName = GetSessionValue(SessionValues.FullName);

            if (sessionFullName == null)
            {
                ProfileViewModel profile = ProfileAppService.GetByUserId(userId, ProfileType.Personal);
                if (profile != null)
                {
                    SetSessionValue(SessionValues.FullName, profile.Name);
                }
            }
        }
예제 #16
0
        protected ProfileViewModel SetAuthorDetails(UserGeneratedBaseViewModel vm)
        {
            if (vm == null)
            {
                return(null);
            }

            if (vm.Id == Guid.Empty || vm.UserId == Guid.Empty)
            {
                vm.UserId = CurrentUserId;
            }

            ProfileViewModel profile = ProfileAppService.GetUserProfileWithCache(vm.UserId);

            if (profile != null)
            {
                vm.AuthorName    = profile.Name;
                vm.AuthorPicture = UrlFormatter.ProfileImage(vm.UserId);
            }

            return(profile);
        }
예제 #17
0
 public virtual Task <ProfileDto> GetLoginInfoAsync()
 {
     return(ProfileAppService.GetAsync());
 }
예제 #18
0
 public virtual Task ChangePasswordAsync(ChangePasswordInput input)
 {
     return(ProfileAppService.ChangePasswordAsync(input));
 }
예제 #19
0
        public async Task <IActionResult> CheckUserInconsistencies()
        {
            List <string> messages = new List <string>();
            OperationResultListVo <string> result = new OperationResultListVo <string>(messages)
            {
                Message = "Check User Inconsistencies Task"
            };

            try
            {
                IQueryable <ApplicationUser> allUsers = await GetUsersAsync();

                OperationResultListVo <ProfileViewModel> profileResult = ProfileAppService.GetAll(CurrentUserId, true);

                if (!profileResult.Success)
                {
                    return(View("TaskResult", profileResult));
                }

                foreach (ProfileViewModel profile in profileResult.Value)
                {
                    ApplicationUser user = allUsers.FirstOrDefault(x => x.Id.Equals(profile.UserId.ToString()));
                    if (user == null)
                    {
                        messages.Add($"profile {profile.Name} ({profile.Id}) without user {profile.UserId}");
                    }
                    else
                    {
                        if (string.IsNullOrWhiteSpace(profile.Handler))
                        {
                            messages.Add($"profile {profile.Name} ({profile.Id}) without handler (should be {user.UserName.ToLower()})");
                        }
                        else
                        {
                            if (!profile.Handler.Equals(profile.Handler.ToLower()))
                            {
                                messages.Add($"profile {profile.Name} ({profile.Id}) handler ({profile.Handler}) not lowercase");
                            }
                        }
                    }
                }

                foreach (ApplicationUser user in allUsers)
                {
                    Guid             guid    = Guid.Parse(user.Id);
                    ProfileViewModel profile = profileResult.Value.FirstOrDefault(x => x.UserId == guid);
                    if (profile == null)
                    {
                        messages.Add($"user {user.UserName} ({user.Id}) without profile");
                    }

                    if (user.CreateDate == DateTime.MinValue)
                    {
                        messages.Add($"user {user.UserName} without create date");
                    }
                }
            }
            catch (Exception ex)
            {
                result.Success = false;
                messages.Add(ex.Message);
            }

            result.Value = messages.OrderBy(x => x);

            return(View("TaskResult", result));
        }