Beispiel #1
0
        public static UserNotification SetUser(this UserNotification userNotification, UserAccount user)
        {
            if (userNotification == null)
                return null;

            userNotification.User = user;

            return userNotification;
        }
Beispiel #2
0
        public void SetUser()
        {
            UserAccount user = new UserAccount() { FirstName = "Pedro", LastName = "Torrezão" };

            UserNotification userNotification = UserNotification.LastLogin(user);

            userNotification.SetUser(user);

            Assert.IsTrue(userNotification.User == user);
        }
Beispiel #3
0
 public static UserNotification LastLogin(UserAccount user)
 {
     return new UserNotification()
     {
         Type = NotificationType.Login,
         Read = false,
         User = user,
         Icon = "search-minus",
         IconColor = TextColor.Blue,
         Title = string.Format("Welcome back {0} last time you been here was {1}.", user.FirstName, user.LastLoginDate.ToString())
     };
 }
        public void UpdateAccount_NonExistingUser()
        {
            //// Create User
            var username = Guid.NewGuid().ToString().Substring(0, 10) + "@email.com";
            var newName = "B";
            var user = new UserAccount();
            user.Username = username;
            user.FirstName = newName;

            var sucess = usrMngSvc.UpdateAccount(user);
            Assert.IsFalse(sucess, "Couldn't update user.");
        }
Beispiel #5
0
        public UserAccount CreateUser(string name, string userName, string password)
        {
            using (var context = new PhobosCoreContext())
            {
                Configuration salt = CoreRepository.GetConfiguration("PasswordSalt");

                var newUser = new UserAccount();
                newUser.FirstName = name;
                newUser.Username = userName;
                newUser.Password = password;
                newUser.MemberSinceDate = DateTime.Now;

                newUser.Roles.AddRange(this.GetRolesForUser(context));

                context.Users.Add(newUser);
                context.SaveChanges();
                return newUser;
            }
        }
Beispiel #6
0
        public bool UpdateAccount(UserAccount userAccount)
        {
            using (var context = new PhobosCoreContext())
            {
                var selectedUser = context.Users.FirstOrDefault(x => x.Username == userAccount.Username);

                if (selectedUser != default(UserAccount))
                {
                    selectedUser.BirthDate = userAccount.BirthDate;
                    selectedUser.CurrentStatus = userAccount.CurrentStatus;
                    selectedUser.FirstName = userAccount.FirstName;
                    selectedUser.LastName = userAccount.LastName;
                    selectedUser.MemberSinceDate = userAccount.MemberSinceDate;
                    selectedUser.Position = userAccount.Position;
                    selectedUser.IsLocked = userAccount.IsLocked;
                    selectedUser.LockedDate = userAccount.LockedDate;
                    selectedUser.LastLoginDate = userAccount.LastLoginDate;
                    context.SaveChanges();
                    return true;
                }

                return false;
            }
        }
        public bool UpdateAccount(UserAccount userAccount)
        {
            var selectedUser = users.FirstOrDefault(x => x.Username == userAccount.Username);

            if (selectedUser != default(UserAccount))
            {
                selectedUser.BirthDate = userAccount.BirthDate;
                selectedUser.CurrentStatus = userAccount.CurrentStatus;
                selectedUser.FirstName = userAccount.FirstName;
                selectedUser.LastName = userAccount.LastName;
                selectedUser.MemberSinceDate = userAccount.MemberSinceDate;
                selectedUser.Position = userAccount.Position;
                selectedUser.IsLocked = userAccount.IsLocked;
                selectedUser.LockedDate = userAccount.LockedDate;
                selectedUser.LastLoginDate = userAccount.LastLoginDate;
                return true;
            }

            return false;
        }
        public UserAccount CreateUser(string name, string userName, string password)
        {
            Configuration salt = this.GetConfiguration("PasswordSalt");

            var newUser = new UserAccount();
            newUser.FirstName = name;
            newUser.Username = userName;
            newUser.Password = password;
            newUser.MemberSinceDate = DateTime.Now;

            newUser.Roles.AddRange(this.GetRolesForUser());

            users.Add(newUser);
            return newUser;
        }