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)); }
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))); } }
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; } } }
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)); }
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); } } }