Beispiel #1
0
        public async Task <string> UpdateAUser(UserSummary user, Location location)
        {
            var sql = @"
                update
                    Users
                set 
                    FirstName = @FirstName,
                    LastName = @LastName,
                    LocationId = @LocationId
                where 
                    Id = @Id
            ;";

            using var connection = new SqlConnection(connectionString);
            connection.Open();
            int result = await connection.ExecuteAsync(sql, new
            {
                Id         = user.UserID,
                FirstName  = user.FirstName,
                LastName   = user.LastName,
                LocationId = location.Id
            });

            return(result == 1 ? user.UserID : "-1");
        }
Beispiel #2
0
 public bool IsValidNominee(UserSummary user)
 {
     if (user.State != UserState.Active) return false;
     return OpenNomination ||
            (null != NomineeGroups && NomineeGroups.Contains(user.Group)) ||
            (null != NomineeUsers && NomineeUsers.Contains(user.Id));
 }
        /// <summary>
        /// Attempts to login a returning user
        /// </summary>
        public bool ReturnLogin(int userId, out UserSummary userSummary)
        {
            if (userId <= 0)
            {
                throw new ArgumentOutOfRangeException("userId");
            }

            userSummary = null;

            var matchingUser = this.Repository.GetSet <User>()
                               .Include(x => x.UserAdmin)
                               .Include(x => x.UserPartnerAdmins)
                               .FirstOrDefault(x => x.UserId == userId);

            if (matchingUser == null)
            {
                return(false);
            }

            // Log Login and get Summary
            this.TrackLogin(matchingUser.UserId);
            userSummary = Mapper.Map(matchingUser, new UserSummary());

            return(true);
        }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            this.ConfirmationWeb.ScriptNotify        += this.WebNotify;
            this.ConfirmationWeb.NavigationCompleted += this.InjectCode;
            this.ConfirmationWeb.NavigationFailed    += this.NavFailed;
            this.ChatWeb.NavigationFailed            += this.NavFailed;
            HardwareButtons.BackPressed += this.BackPressed;

            if (e.Parameter is string)
            {
                var steamid = ulong.Parse((string)e.Parameter);
                Storage.SetCurrentUser(steamid);

                this.account = Storage.GetSteamGuardAccount();
                this.ConfirmationsButton_Click(null, null);
            }
            else
            {
                this.account = Storage.GetSteamGuardAccount();
                this.SteamGuardButton_Click(null, null);
            }

            if (this.account != null && (DateTime.UtcNow - this.account.DisplayCache).Days > 1)
            {
                UserSummary.GetSummaries(this.web, this.account.Session, new [] { this.account.Session.SteamID }, this.SummariesCallback);
            }
        }
        public async void UpdateUser_TryBlock_InvalidUser_ReturnInternalServerException()
        {
            Setup_LocationsRepo_GetALocation_Default(new Location());
            Setup_UsersRepo_UpdateAUser_Default("-1");
            var errMessage = "Internal Server Error";
            var location   = new LocationResource {
                LocationID = 1,
                City       = "city",
                Province   = "province"
            };
            var summary = new UserSummary {
                UserID             = "1",
                Location           = location,
                FirstName          = "first",
                LastName           = "last",
                Utilization        = 0,
                ResourceDiscipline = null,
                IsConfirmed        = false
            };
            var user = new UserProfile {
                UserSummary     = summary,
                CurrentProjects = Enumerable.Empty <ProjectSummary>(),
                Availability    = Enumerable.Empty <OutOfOfficeResource>(),
                Disciplines     = Enumerable.Empty <ResourceDisciplineResource>(),
                Positions       = Enumerable.Empty <PositionSummary>()
            };

            var result = (await _controller.UpdateUser(user, "1")) as ObjectResult;

            Assert.Equal(StatusCodes.Status500InternalServerError, result.StatusCode);
            var response = result.Value as InternalServerException;

            Assert.Equal(errMessage, response.status);
        }
        public async Task Initialize <TTemplate>(UserSummary user, TTemplate mailTemplate)
            where TTemplate : UserMailTemplateBase
        {
            if (mailTemplate == null)
            {
                throw new ArgumentNullException(nameof(mailTemplate));
            }
            if (user == null)
            {
                throw new ArgumentNullException(nameof(user));
            }

            mailTemplate.User            = user;
            mailTemplate.ApplicationName = await GetApplicationNameAsync();

            if (mailTemplate is IMailTemplateWithSignInUrl mailTemplateWithSignInUrl)
            {
                mailTemplateWithSignInUrl.SignInUrl = GetSignInUrl(user);
            }

            if (user.UserArea.UserAreaCode == CofoundryAdminUserArea.Code)
            {
                mailTemplate.LayoutFile = AdminMailTemplatePath.LayoutPath;
                mailTemplate.ViewFile   = AdminMailTemplatePath.TemplateView(mailTemplate.GetType().Name);
            }
        }
Beispiel #7
0
 // Token: 0x0600F5A3 RID: 62883 RVA: 0x0040FB68 File Offset: 0x0040DD68
 public void InitPlayerInfo(UserSummary player, bool isInvited)
 {
     if (!BJLuaObjHelper.IsSkipLuaHotfix && this.TryInitHotFix("") && this.m_InitPlayerInfoUserSummaryBoolean_hotfix != null)
     {
         this.m_InitPlayerInfoUserSummaryBoolean_hotfix.call(new object[]
         {
             this,
             player,
             isInvited
         });
         return;
     }
     BJLuaObjHelper.IsSkipLuaHotfix = false;
     this.m_isAdd      = isInvited;
     this.InvitePlayer = player;
     base.gameObject.SetActive(true);
     this.m_headIcon.sprite = AssetUtility.Instance.GetSprite(UIUtility.GetPlayerSmallHeadIconImageName(HeadIconTools.GetHeadPortrait(player.HeadIcon)));
     UIUtility.SetPlayerHeadFrame(this.m_HeadFrameDummy, HeadIconTools.GetHeadFrame(player.HeadIcon), true, "Normal");
     this.m_levelText.text = player.Level.ToString();
     this.m_nameText.text  = player.Name.ToString();
     this.m_powerText.text = player.TopHeroBattlePower.ToString();
     this.m_onlineStateCtrl.SetToUIState((!player.Online) ? "Offline" : "Online", false, true);
     this.m_headIconStateCtrl.SetToUIState((!player.Online) ? "Offline" : "Online", false, true);
     if (!player.Online)
     {
         this.m_OffLineText.text    = UIUtility.GetMemberOnlineText(player.Online, player.LogoutTime);
         this.m_headIconGrey.sprite = AssetUtility.Instance.GetSprite(UIUtility.GetPlayerSmallHeadIconImageName(HeadIconTools.GetHeadPortrait(player.HeadIcon)));
     }
     this.m_addButtonStateCtrl.SetToUIState((!this.m_isAdd) ? "Add" : "Done", false, true);
 }
 // Token: 0x0600F532 RID: 62770 RVA: 0x0040EBAC File Offset: 0x0040CDAC
 public void InitItemInfo(UserSummary player)
 {
     if (!BJLuaObjHelper.IsSkipLuaHotfix && this.TryInitHotFix("") && this.m_InitItemInfoUserSummary_hotfix != null)
     {
         this.m_InitItemInfoUserSummary_hotfix.call(new object[]
         {
             this,
             player
         });
         return;
     }
     BJLuaObjHelper.IsSkipLuaHotfix = false;
     this.Player = player;
     base.gameObject.SetActive(true);
     this.m_headIcon.sprite = AssetUtility.Instance.GetSprite(UIUtility.GetPlayerSmallHeadIconImageName(HeadIconTools.GetHeadPortrait(player.HeadIcon)));
     UIUtility.SetPlayerHeadFrame(this.m_HeadFrameDummy, HeadIconTools.GetHeadFrame(player.HeadIcon), true, "Normal");
     this.m_levelText.text = player.Level.ToString();
     this.m_nameText.text  = player.Name;
     this.m_powerText.text = player.TopHeroBattlePower.ToString();
     this.m_headIconStateCtrl.SetToUIState((!player.Online) ? "Offline" : "Online", false, true);
     if (!player.Online)
     {
         this.m_headIconGrey.sprite = AssetUtility.Instance.GetSprite(UIUtility.GetPlayerSmallHeadIconImageName(HeadIconTools.GetHeadPortrait(player.HeadIcon)));
     }
 }
Beispiel #9
0
        public ActionResult CompleteResetPassword(string id, UserSummary summary)
        {
            if (RoadkillSettings.UseWindowsAuthentication)
                return RedirectToAction("Index", "Home");

            // Don't use ModelState.isvalid as the summary object only has an ID and two passwords
            if (UserSummary.VerifyPassword(summary,null) != ValidationResult.Success ||
                UserSummary.VerifyPasswordsMatch(summary,null) != ValidationResult.Success)
            {
                ModelState.Clear();
                ModelState.AddModelError("Passwords", SiteStrings.ResetPassword_Error);
                return View(summary);
            }
            else
            {
                User user = UserManager.Current.GetUserByResetKey(id);
                if (user != null)
                {
                    UserManager.Current.ChangePassword(user.Email, summary.Password);
                    return View("CompleteResetPasswordSuccessful");
                }
                else
                {
                    return View("CompleteResetPasswordInvalid");
                }
            }
        }
        public void UserSummary_ToJson_ThenToXml_ThenToJson_BackToUserSummary()
        {
            var user = new UserSummary
            {
                UserName           = "******",
                Email              = "*****@*****.**",
                FirstName          = "Jimmy",
                LastName           = "Bobby",
                PrimaryPhoneNumber = "555-1212",
                MobilePhoneNumber  = "858-555-1212",
                ProfileIds         = "Profile1, Profile 2",
                Address1           = "123 Happy St",
                Address2           = null,
                City          = "San Diego",
                StateProvince = "CA",
                ZipCode       = "92109",
                Country       = "United States"
            };

            var result = SerializeToJsonThenToXmlThenToJsonThenTo(user);

            Assert.AreEqual(user.UserName, result.UserName);
            Assert.AreEqual(user.Address1, result.Address1);
            Assert.AreEqual(user.Address2, result.Address2);
            Assert.AreEqual(user.City, result.City);
            Assert.AreEqual(user.Country, result.Country);
            Assert.AreEqual(user.Email, result.Email);
            Assert.AreEqual(user.FirstName, result.FirstName);
            Assert.AreEqual(user.LastName, result.LastName);
            Assert.AreEqual(user.MobilePhoneNumber, result.MobilePhoneNumber);
            Assert.AreEqual(user.PrimaryPhoneNumber, result.PrimaryPhoneNumber);
            Assert.AreEqual(user.ZipCode, result.ZipCode);
            Assert.AreEqual(user.ProfileIds, result.ProfileIds);
        }
        internal static void UpdateUserAccount(string userName, StaffSummary staff)
        {
            if (!string.IsNullOrEmpty(userName))
            {
                Platform.GetService <IUserAdminService>(
                    delegate(IUserAdminService service)
                {
                    // check if the user account exists
                    ListUsersRequest request = new ListUsersRequest();
                    request.UserName         = userName;
                    request.ExactMatchOnly   = true;
                    UserSummary user         = CollectionUtils.FirstElement(service.ListUsers(request).Users);

                    if (user != null)
                    {
                        // modify the display name on the user account
                        UserDetail detail = service.LoadUserForEdit(
                            new LoadUserForEditRequest(userName)).UserDetail;
                        detail.DisplayName = (staff == null) ? null : staff.Name.ToString();

                        service.UpdateUser(new UpdateUserRequest(detail));
                    }
                });
            }
        }
Beispiel #12
0
 public bool CanDistributeBudget(User fromManager, UserSummary toUser)
 {
     // user directly report to current user or be in one of the
     // groups this user manages
     return(toUser.Manager == fromManager.Document.Id ||
            (!String.IsNullOrEmpty(toUser.Group) &&
             fromManager.ManagedGroups != null &&
             fromManager.ManagedGroups.Contains(toUser.Group)));
 }
 private async Task OnTransactionComplete(UserSummary user, AddAuthorizedTaskCommand addAuthorizedTaskCommand)
 {
     await _messageAggregator.PublishAsync(new UserAccountRecoveryInitiatedMessage()
     {
         AuthorizedTaskId = addAuthorizedTaskCommand.OutputAuthorizedTaskId,
         UserAreaCode     = user.UserArea.UserAreaCode,
         UserId           = user.UserId,
         Token            = addAuthorizedTaskCommand.OutputToken
     });
 }
        public IPasswordChangedTemplateBuilderContext CreatePasswordChangedContext(UserSummary user)
        {
            var context = new PasswordChangedTemplateBuilderContext()
            {
                User = user,
                DefaultTemplateFactory = PasswordChangedTemplateFactory
            };

            return(context);
        }
Beispiel #15
0
 internal UserInfo(PixivClient client, UserSummary api)
 {
     Client     = client;
     Id         = api.Id;
     Name       = api.Name;
     Account    = api.Account;
     IsFollowed = api.IsFollowed;
     Comment    = api.Comment;
     _avatarUri = api.ProfileImageUrls.Medium;
 }
Beispiel #16
0
 public bool IsValidNominee(UserSummary user)
 {
     if (user.State != UserState.Active)
     {
         return(false);
     }
     return(OpenNomination ||
            (null != NomineeGroups && NomineeGroups.Contains(user.Group)) ||
            (null != NomineeUsers && NomineeUsers.Contains(user.Id)));
 }
        public async Task <ModalResult> ShowUserModal(UserSummary user)
        {
            var modalParams = new ModalParameters();

            modalParams.Add("Id", user.Id);
            modalParams.Add("IsModal", true);

            var modal = _modalService.Show <ViewUser>("User", modalParams, DefaultModalOptions);

            return(await modal.Result);
        }
Beispiel #18
0
 private static UserSummaryResponse ToUserSummaryResponse(UserSummary summary) => new UserSummaryResponse
 {
     Name    = summary.User,
     Balance = summary.Balances.Sum(x => x.Value),
     Owes    = summary.Balances
               .Where(x => x.Value < 0)
               .ToImmutableSortedDictionary(x => x.Key, x => - x.Value),
     OwedBy = summary.Balances
              .Where(x => x.Value > 0)
              .ToImmutableSortedDictionary(x => x.Key, x => x.Value),
 };
        public IPasswordResetTemplateBuilderContext CreatePasswordResetContext(UserSummary user, string temporaryPassword)
        {
            var context = new PasswordResetTemplateBuilderContext()
            {
                User = user,
                TemporaryPassword      = new HtmlString(temporaryPassword),
                DefaultTemplateFactory = PasswordResetTemplateFactory
            };

            return(context);
        }
        public User EditUser(UserSummary userSummary, int userId)
        {
            var user = userRepository.GetById(userId);

            user.Email     = userSummary.Email;
            user.StoreID   = userSummary.StoreID;
            user.FirstName = userSummary.FirstName;
            user.LastName  = userSummary.LastName;
            user.IsActive  = userSummary.IsActive;
            return(userRepository.ModifyUser(user));
        }
Beispiel #21
0
        private User createUserFromSummary(UserSummary summary, Location location)
        {
            var user = new User
            {
                Id         = summary.UserID,
                FirstName  = summary.FirstName,
                LocationId = location.Id,
                LastName   = summary.LastName
            };

            return(user);
        }
        public async Task <ModalResult> ShowMessageModal(UserSummary recipient, string subject)
        {
            var modalParams = new ModalParameters();

            modalParams.Add("Recipient", recipient);
            modalParams.Add("Subject", subject);
            modalParams.Add("IsModal", true);

            var modal = _modalService.Show <MessageViewer>("Message", modalParams, DefaultModalOptions);

            return(await modal.Result);
        }
Beispiel #23
0
        public UserSummary Summary()
        {
            var profile           = MvcContext.Current.UserPassport.Profile;
            var userWallet        = Wallet.FindByOwnerId(WalletType.Privateness, profile.PassportId);
            var resumeIntegrality = 0;

            var userSummary = new UserSummary(profile);

            userSummary.WalletBalance     = null == userWallet ? 0 : userWallet.AvailableBalance;
            userSummary.ResumeIntegrality = resumeIntegrality;

            return(userSummary);
        }
Beispiel #24
0
 public async Task StartMasteryAlert(UserSummary userSummary, GameInfoAndProgress gameInfo)
 {
     await ExecuteScript(
         "masteryTitle.innerHTML = \"" + gameInfo.Title.Replace("\"", "\\\"") + "\";" +
         "masteryAchievements.innerHTML = \"Cheevos: " + userSummary.AchievmentsPossible + "\";" +
         "masteryPoints.innerHTML = \"Points: " + userSummary.GamePointsPossible + "\";" +
         "$(\"#mastery-badge\").attr(\"src\", \"https:retroachievements.org" + gameInfo.ImageIcon + "\");" +
         "$(\"#mastery-video\").attr(\"src\", \"disk://mastery-notification\");" +
         "masteryVideoElement.style.display = \"block\";" +
         "masteryElement.style.display = \"block\";" +
         "textFit(masteryTitle, { alignVert: true, alignHoriz: true });" +
         "textFit(masteryPoints, { alignVert: true, alignHoriz: true });" +
         "textFit(masteryAchievements, { alignVert: true, alignHoriz: true });");
 }
        public User CreateUser(UserSummary userSummary)
        {
            //todo mapper
            var user = new User
            {
                Email     = userSummary.Email,
                StoreID   = userSummary.StoreID,
                FirstName = userSummary.FirstName,
                LastName  = userSummary.LastName,
                IsActive  = userSummary.IsActive
            };

            return(userRepository.AddUser(user));
        }
Beispiel #26
0
    public MemberBan(
        [JsonProperty(Required = Required.Always)]
        UserSummary user,

        [JsonProperty(Required = Required.Always)]
        HashId createdBy,

        [JsonProperty(Required = Required.Always)]
        DateTime createdAt,

        [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
        string?reason = null
        ) =>
    (User, CreatedBy, CreatedAt, Reason) = (user, createdBy, createdAt, reason);
        protected void ConfigureQueryUsers(int number)
        {
            var users = new UserSummary[number];

            for (var i = 0; i < number; i++)
            {
                users[i] = new UserSummary {
                    Subject = i.ToString()
                };
            }
            identityManager.SetupQueryUsersAsync(new QueryResult <UserSummary> {
                Items = users
            });
        }
Beispiel #28
0
        public void GetUserData(out List <UserSummary> userSummaries, out List <UserCumulate> userCumulates)
        {
            userSummaries = new List <UserSummary>();
            userCumulates = new List <UserCumulate>();
            CultureInfo provider = CultureInfo.InvariantCulture;

            string beginDate = DateTime.Now.AddDays(-7).ToString("yyyy-MM-dd");
            string endDate   = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd");

            JObject posJObject = new JObject
            {
                { "begin_date", beginDate },
                { "end_date", endDate }
            };
            string urlGetusersummary  = $"https://api.weixin.qq.com/datacube/getusersummary?access_token={_accessToken}";
            string urlGetusercumulate = $"https://api.weixin.qq.com/datacube/getusercumulate?access_token={_accessToken}";

            string  outGetusersummary        = Requests.HttpPost(urlGetusersummary, posJObject.ToString());
            JObject outGetusersummaryJObject = JObject.Parse(outGetusersummary);
            JArray  usersummaryJArray        = JArray.FromObject(outGetusersummaryJObject["list"]);

            foreach (var usersummary in usersummaryJArray.Children())
            {
                JObject     itemJObject = JObject.FromObject(usersummary);
                UserSummary userSummary = new UserSummary
                {
                    ref_date    = DateTime.ParseExact((string)itemJObject["ref_date"], "yyyy-MM-dd", provider),
                    user_source = (int)itemJObject["user_source"],
                    new_user    = (int)itemJObject["new_user"],
                    cancel_user = (int)itemJObject["cancel_user"]
                };
                userSummaries.Add(userSummary);
            }

            string  outGetusercumulate        = Requests.HttpPost(urlGetusercumulate, posJObject.ToString());
            JObject outGetusercumulateJObject = JObject.Parse(outGetusercumulate);
            JArray  usercumulateJArray        = JArray.FromObject(outGetusercumulateJObject["list"]);

            foreach (var usercumulate in usercumulateJArray.Children())
            {
                JObject      itemJObject  = JObject.FromObject(usercumulate);
                UserCumulate userCumulate = new UserCumulate
                {
                    ref_date      = DateTime.ParseExact((string)itemJObject["ref_date"], "yyyy-MM-dd", provider),
                    cumulate_user = (int)itemJObject["cumulate_user"]
                };
                userCumulates.Add(userCumulate);
            }
        }
Beispiel #29
0
 public void InsertUser(Guid user, string name, string password, string status)
 {
     using (var db = new QueryDbContext(DatabaseConnectionString))
     {
         var summary = new UserSummary
         {
             UserIdentifier         = user,
             LoginName              = name,
             LoginPassword          = password,
             UserRegistrationStatus = status
         };
         db.UserSummaries.Add(summary);
         db.SaveChanges();
     }
 }
        public string GetSignInUrl(UserSummary user)
        {
            string signInPath;

            if (user.UserArea.UserAreaCode == CofoundryAdminUserArea.Code)
            {
                signInPath = "/" + _adminSettings.DirectoryName;
            }
            else
            {
                var options = _userAreaDefinitionRepository.GetRequiredByCode(user.UserArea.UserAreaCode);
                signInPath = options.SignInPath;
            }

            return(_siteUrlResolver.MakeAbsolute(signInPath));
        }
Beispiel #31
0
 public void WriteStatsStreamLabels(UserSummary userSummary, GameInfoAndProgress gameInfoAndProgress)
 {
     if (userSummary != null)
     {
         File.WriteAllText(@Directory.GetCurrentDirectory() + "/stream-labels/stats/rank.txt", userSummary.Rank.ToString());
         File.WriteAllText(@Directory.GetCurrentDirectory() + "/stream-labels/stats/awards.txt", userSummary.Awards.ToString());
         File.WriteAllText(@Directory.GetCurrentDirectory() + "/stream-labels/stats/ratio.txt", userSummary.RetroRatio);
         File.WriteAllText(@Directory.GetCurrentDirectory() + "/stream-labels/stats/points.txt", userSummary.TotalPoints.ToString());
         File.WriteAllText(@Directory.GetCurrentDirectory() + "/stream-labels/stats/true-points.txt", userSummary.TotalTruePoints.ToString());
         File.WriteAllText(@Directory.GetCurrentDirectory() + "/stream-labels/stats/game-ratio.txt", gameInfoAndProgress.GameTruePointsPossible == 0 ? "0" : (Convert.ToDecimal(gameInfoAndProgress.GameTruePointsPossible) / Convert.ToDecimal(userSummary.GamePointsPossible)).ToString("0.00"));
         File.WriteAllText(@Directory.GetCurrentDirectory() + "/stream-labels/stats/game-points.txt", userSummary.GamePointsEarned == 0 ? "0 / 0" : userSummary.GamePointsEarned.ToString() + "/" + userSummary.GamePointsPossible.ToString());
         File.WriteAllText(@Directory.GetCurrentDirectory() + "/stream-labels/stats/game-true-points.txt", gameInfoAndProgress.GameTruePointsEarned == 0 ? "0 / 0" : gameInfoAndProgress.GameTruePointsEarned.ToString() + "/" + gameInfoAndProgress.GameTruePointsPossible.ToString());
         File.WriteAllText(@Directory.GetCurrentDirectory() + "/stream-labels/stats/game-achievements.txt", userSummary.Achievements.Count(achievement => achievement.HardcoreAchieved).ToString() + "/" + userSummary.Achievements.Count);
         File.WriteAllText(@Directory.GetCurrentDirectory() + "/stream-labels/stats/completed.txt", (userSummary.Achievements.Count == 0 ? 0 : Convert.ToInt32(Convert.ToDecimal(userSummary.Achievements.Count(achievement => achievement.HardcoreAchieved)) / Convert.ToDecimal(userSummary.Achievements.Count) * 200)) + " %");
     }
 }
Beispiel #32
0
        public List <UserSummary> GetSummaryData(string summaryDate)
        {
            try
            {
                var usersData    = new List <UserSummary>();
                var dbConnection = new SqlConnection(
                    _config.GetConnectionString("primary"));
                var command = new SqlCommand("Get_Summary_Data", dbConnection);
                command.CommandType = System.Data.CommandType.StoredProcedure;
                command.Parameters.Add("@SummaryDate", System.Data.SqlDbType.Date).Value = summaryDate;

                dbConnection.Open();
                var dataReader = command.ExecuteReader();
                while (dataReader.Read())
                {
                    bool isNewUser   = false;
                    int  userId      = (int)dataReader["UserId"];
                    var  userSummary = usersData.Find(x => x.UserId == userId);
                    if (userSummary is null)
                    {
                        isNewUser   = true;
                        userSummary = new UserSummary(userId);
                    }

                    var subjectSummary = new SubjectSummary(
                        (string)dataReader["Subject"],
                        (int)dataReader["AnswersSubmitted"],
                        (int)dataReader["CorrectAnswers"],
                        (int)dataReader["Progress"]
                        );
                    userSummary.Subjects.Add(subjectSummary);

                    if (isNewUser)
                    {
                        usersData.Add(userSummary);
                    }
                }
                dbConnection.Close();

                return(usersData);
            }
            catch (Exception ex)
            {
                LogError(ex.Message);
                return(null);
            }
        }
Beispiel #33
0
        public ActionResult AddAdmin(UserSummary summary)
        {
            if (ModelState.IsValid)
            {
                UserManager.Current.AddUser(summary.NewEmail, summary.NewUsername, summary.Password, true, false);

                // TODO
                // ModelState.AddModelError("General", errors);
            }
            else
            {
                // Instructs the view to reshow the modal dialog
                TempData["action"] = "addadmin";
            }

            return RedirectToAction("Users");
        }
Beispiel #34
0
        public ActionResult AddEditor(UserSummary summary)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    UserManager.Current.AddUser(summary.NewEmail, summary.NewUsername, summary.Password, false, true);
                }
                catch (SecurityException e)
                {
                    ModelState.AddModelError("General", e.Message);
                }
            }
            else
            {
                // Instructs the view to reshow the modal dialog
                TempData["action"] = "addeditor";
            }

            return RedirectToAction("Users");
        }
Beispiel #35
0
        public ActionResult EditUser(UserSummary summary)
        {
            if (ModelState.IsValid)
            {
                if (summary.UsernameHasChanged)
                {
                    if (!UserManager.Current.UpdateUser(summary))
                    {
                        ModelState.AddModelError("General", SiteStrings.SiteSettings_Users_EditUser_Error);
                    }

                    summary.ExistingEmail = summary.NewEmail;
                }

                if (!string.IsNullOrEmpty(summary.Password))
                    UserManager.Current.ChangePassword(summary.ExistingEmail, summary.Password);
            }
            else
            {
                // Instructs the view to reshow the modal dialog
                TempData["action"] = "edituser";
            }

            return RedirectToAction("Users");
        }
 public bool CanDistributeBudget(User fromManager, UserSummary toUser)
 {
     // user directly report to current user or be in one of the
     // groups this user manages
     return toUser.Manager == fromManager.Document.Id ||
              (!String.IsNullOrEmpty(toUser.Group) &&
               fromManager.ManagedGroups != null &&
               fromManager.ManagedGroups.Contains(toUser.Group));
 }
Beispiel #37
0
        public ActionResult Signup(UserSummary summary, bool? isCaptchaValid)
        {
            if (RoadkillContext.Current.IsLoggedIn || !RoadkillSettings.AllowUserSignup || RoadkillSettings.UseWindowsAuthentication)
                return RedirectToAction("Index","Home");

            if (ModelState.IsValid)
            {
                if (isCaptchaValid.HasValue && isCaptchaValid == false)
                {
                    // Invalid recaptcha
                    ModelState.AddModelError("General", SiteStrings.Signup_Error_Recaptcha);
                }
                else
                {
                    // Everything is valid.
                    try
                    {
                        try
                        {
                            string key = UserManager.Current.Signup(summary, null);
                            if (string.IsNullOrEmpty(key))
                            {
                                ModelState.AddModelError("General", SiteStrings.Signup_Error_General);
                            }
                            else
                            {
                                // Send the confirm email
                                Email.Send(new SignupEmail(summary));
                                return View("SignupComplete", summary);
                            }
                        }
                        catch (SecurityException e)
                        {
                            ModelState.AddModelError("General", e.Message);
                        }
                    }
                    catch (SecurityException e)
                    {
                        ModelState.AddModelError("General", e.Message);
                    }
                }
            }

            return View();
        }
Beispiel #38
0
        public ActionResult Profile(UserSummary summary)
        {
            if (!RoadkillContext.Current.IsLoggedIn)
                return RedirectToAction("Login");

            // If the ID (and probably IsNew) have been tampered with in an attempt to create new users, just redirect.
            // We can't set summary.IsNew=false here as it's already been validated.
            if (summary.Id == null || summary.Id == Guid.Empty)
                return RedirectToAction("Login");

            #if APPHARBOR
            ModelState.AddModelError("General", "The demo site login cannot be changed.");
            #endif

            if (ModelState.IsValid)
            {
                try
                {
                    if (!UserManager.Current.UpdateUser(summary))
                    {
                        ModelState.AddModelError("General", SiteStrings.Profile_Error);
                        summary.ExistingEmail = summary.NewEmail;
                    }

                    if (!string.IsNullOrEmpty(summary.Password))
                        UserManager.Current.ChangePassword(summary.ExistingEmail, summary.Password);
                }
                catch (SecurityException e)
                {
                    ModelState.AddModelError("General", e.Message);
                }
            }

            return View(summary);
        }