示例#1
0
        /// <summary>
        /// William Clark
        /// Created: 2021/03/11
        ///
        /// Constructs a GroupMember list
        /// </summary>
        ///
        /// <remarks>
        /// </remarks>
        ///
        /// <param name="userGroups">The UserGroups for which this list will display</param>
        /// <param name="userGroupManager">The UserGroupManager reference</param>
        /// <param name="userManager">The UserManager reference</param>
        /// <param name="role">The role for which this list will display. "Admin", "Client"</param>
        public GroupMemberList(List <UserGroup> userGroups, IUserGroupManager userGroupManager, IUserManager userManager, UserAccountVM user, String role)
        {
            InitializeComponent();

            _userGroups       = userGroups;
            _userGroupManager = userGroupManager;
            _userManager      = userManager;
            _user             = user;

            switch (role)
            {
            case "Admin":
                _clientList             = PopulateList("Client");
                dgFirstList.ItemsSource = _clientList;

                _caregiverList           = PopulateList("Caregiver");
                dgSecondList.ItemsSource = _caregiverList;
                break;

            case "Client":
                _adminList = PopulateList("Admin");
                dgFirstList.ItemsSource = _adminList;

                _caregiverList           = PopulateList("Caregiver");
                dgSecondList.ItemsSource = _caregiverList;
                break;

            default:
                break;
            }
            frmSelectedUser.Navigate(new UserGroupMemberEditDetail(_user));
        }
示例#2
0
 public IActionResult Register(UserAccountVM userRegister)
 {
     if (ModelState.IsValid)
     {
     }
     return(View("Login"));
 }
示例#3
0
 public IActionResult ChangePassword(UserAccountVM userRegister)
 {
     if (ModelState.IsValid)
     {
     }
     return(View());
 }
示例#4
0
 public IActionResult Profile(UserAccountVM userRegister)
 {
     if (ModelState.IsValid)
     {
     }
     return(View());
 }
示例#5
0
 public IActionResult Login(UserAccountVM userLogin)
 {
     if (ModelState.IsValid)
     {
     }
     return(View());
 }
示例#6
0
 /// <summary>
 /// William Clark
 /// Created: 2021/03/11
 ///
 /// Constructs an ActiveRoutines page
 /// </summary>
 ///
 /// <remarks>
 /// </remarks>
 ///
 /// <param name="routineManager">The RoutineManager Reference</param>
 /// <param name="selectedUser">The UserAccountVM for which to view active routines</param>
 public ActiveRoutines(RoutineManager routineManager, UserAccountVM selectedUser)
 {
     _routineManager = routineManager;
     _user           = selectedUser;
     InitializeComponent();
     PopulateRoutineList();
 }
        /// <summary>
        /// William Clark
        /// Created: 2021/02/25
        ///
        /// Selects a UserAccountVM from the database with the matching UserAccountID field
        /// </summary>
        ///
        /// <remarks>
        /// </remarks>
        ///
        /// <param name="userAccountID">The UserAccountID of the UserAccount to be selected</param>
        /// <exception>No UserAccount found</exception>
        /// <returns>A UserAccountVM object</returns>
        public UserAccountVM SelectUserAccountVMByUserAccount(UserAccount user)
        {
            var           userGroupAccessor = new UserGroupAccessor();
            UserAccountVM userAccountVM     = new UserAccountVM(user, userGroupAccessor.SelectAllMembershipsByUserAccountID(user.UserAccountID));

            return(userAccountVM);
        }
        /// <summary>
        /// William Clark
        /// Created: 2021/03/11
        ///
        /// Constructs a ClientDashboard
        /// </summary>
        ///
        /// <remarks>
        /// </remarks>
        ///
        /// <param name="user">The UserAccount for which to display this dashboard</param>
        public ClientDashboard(UserAccountVM user)
        {
            _user             = user;
            _userGroupManager = new UserGroupManager(new UserGroupFakes());
            _userManager      = new UserManager(new UserFakes());


            InitializeComponent();

            // Instantiates a new group member list page with the groups of which the user is a member
            try
            {
                List <UserGroup> userGroups = new List <UserGroup>();
                foreach (var membership in _user.Memberships)
                {
                    userGroups.Add(_userGroupManager.GetUserGroupByGroupID(membership.GroupID));
                }
                frmGroupMemberList.Navigate(new GroupMemberList(userGroups, _userGroupManager, _userManager, _user, "Client"));
            }
            catch (Exception)
            {
                MessageBox.Show("The Groups you belong to could not be found.");
            }
            lblCurrentDate.Content = DateTime.Today.ToShortDateString();
        }
示例#9
0
        public ActionResult Index(LoginVM model)
        {
            string        password  = model.Password;
            UserAccountVM accountVM = _accountB.Login(model.UserId, password);

            UserId = model.UserId;
            return(View());
        }
示例#10
0
        public bool UserValidation(UserAccountVM user)
        {
            user.Password = encrypt(user.Password);
            bool isValid = db.UserAccounts.Any(x => x.EmailId == user.EmailId && x.Password == user.Password);

            if (isValid)
            {
                // FormsAuthentication.SetAuthCookie(user.EmailId, false);
                return(true);
            }

            return(false);
        }
示例#11
0
        public UserAccountVM Login(string userId, string password)
        {
            Sys_Account account = _sysAccountD.FindSingle(m => m.Account == userId && m.Password == password);

            if (account == null)
            {
                throw new Exception("账号或密码错误");
            }
            //账号密码正确,查找各种权限组织
            UserAccountVM accountVM = new UserAccountVM();

            return(accountVM);
        }
示例#12
0
        public ActionResult Login(UserAccountVM user)
        {
            bool flag = account.SignIn(user);

            if (flag)
            {
                FormsAuthentication.SetAuthCookie(user.EmailId, false);
                return(RedirectToAction("GetDetails", "Shop"));
            }
            else
            {
                ModelState.AddModelError("", "Invalid User or Wrong Password");
            }
            return(View());
        }
示例#13
0
        public void ChangePassword(UserAccountVM vm)
        {
            if (vm?.Password == null || vm.Password != vm.Password2 || vm.Id == 0)
            {
                return;
            }
            var user = UserManager.FindById(vm.Id);

            if (user == null)
            {
                return;
            }
            user.PasswordHash = UserManager.PasswordHasher.HashPassword(vm.Password);
            var result = UserManager.Update(user);
        }
示例#14
0
        public bool RestPassword(UserAccountVM user)
        {
            UserAccount _user = db.UserAccounts.Where(x => x.EmailId == user.EmailId).FirstOrDefault();

            if (_user != null)
            {
                if (user.Password.Equals(user.ConfirmPassword))
                {
                    _user.Password        = encrypt(user.Password);
                    db.Entry(_user).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();
                    return(true);
                }
            }
            return(false);
        }
        /// <summary>
        /// William Clark
        /// Created: 2021/02/25
        ///
        /// Selects dashboard that matches the role with the most authority that a UserAccountVM has in any of their groups
        /// </summary>
        ///
        /// <remarks>
        /// </remarks>
        ///
        /// <param name="userAccountVM">The UserAccountVM for which a dashboard is to be selected</param>
        private void SelectDashboard(UserAccountVM userAccountVM)
        {
            // The interface to present
            // This defaults to the "Admin" dashboard, as UserAccounts will be an "Admin" of a group for themselves unless
            // The account was created by an "Admin"
            String interfaceRole = "Admin";
            bool   searching     = true;

            foreach (var membership in userAccountVM.Memberships)
            {
                while (searching)
                {
                    foreach (var role in membership.Roles)
                    {
                        if (role.Name == "Client")
                        {
                            interfaceRole = "Client";
                            searching     = false;
                            break;
                        }
                        else if (role.Name == "Caregiver")
                        {
                            interfaceRole = "Caregiver";
                            searching     = false;
                            break;
                        }
                    }
                    searching = false;
                }
            }
            switch (interfaceRole)
            {
            case "Admin":
                frmMainFrame.Navigate(new AdministratorDashboard(_userAccountVM));
                break;

            case "Caregiver":
                break;

            case "Client":
                frmMainFrame.Navigate(new ClientDashboard(_userAccountVM));
                break;

            default:
                break;
            }
        }
        /// <summary>
        /// William Clark
        /// Created: 2021/02/24
        ///
        /// Constructs an AdministratorDashboard
        /// </summary>
        ///
        /// <remarks>
        /// </remarks>
        ///
        /// <param name="user">The UserAccountVM for which to display this dashboard</param>
        public AdministratorDashboard(UserAccountVM user)
        {
            _user             = user;
            _userGroupManager = new UserGroupManager(new UserGroupFakes());
            _userManager      = new UserManager(new UserFakes());


            InitializeComponent();

            // Instantiates a new group member list page with the groups of which the user is a member
            try
            {
                frmGroupMemberList.Navigate(new GroupMemberList(_userGroupManager.SelectOwnedUserGroupsByUserAccountID(_user.UserAccountID), _userGroupManager, _userManager, _user, "Admin"));
            }
            catch (Exception)
            {
                MessageBox.Show("The Groups you belong to could not be found.");
            }
        }
示例#17
0
        /// <summary>
        /// William Clark
        /// Created: 2021/02/25
        ///
        /// Selects a UserAccountVM from the database from a UserAccount
        /// </summary>
        ///
        /// <remarks>
        /// </remarks>
        ///
        /// <param name="user">The UserAccount of the UserAccountVM to be selected</param>
        /// <exception>No UserAccountVM found</exception>
        /// <returns>A UserAccountVM object</returns>
        public UserAccountVM SelectUserAccountVMByUserAccount(UserAccount user)
        {
            UserAccountVM        result = null;
            List <UserAccountVM> users  = new List <UserAccountVM>()
            {
                new UserAccountVM(fakeAdmin, fakeAdminMemberships),
                new UserAccountVM(fakeCaregiver, fakeCaregiverMemberships),
                new UserAccountVM(fakeClient, fakeClientMemberships)
            };

            foreach (var useraccount in users)
            {
                if (useraccount.UserAccountID == user.UserAccountID)
                {
                    result = useraccount;
                }
            }
            return(result);
        }
示例#18
0
        public bool RestPassword(UserAccountVM _user)
        {
            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri("https://localhost:44393/api/UserAccount/");
                var responseTask = client.PutAsJsonAsync <UserAccountVM>("RestPassword", _user);
                responseTask.Wait();

                var respResult = responseTask.Result;
                if (respResult.IsSuccessStatusCode)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
示例#19
0
        public bool SignUp(UserAccountVM user)
        {
            UserAccount _user = db.UserAccounts.Where(x => x.EmailId == user.EmailId).FirstOrDefault();

            if (_user == null)
            {
                if (user.Password.Equals(user.ConfirmPassword))
                {
                    UserAccount newAccount = new UserAccount();
                    newAccount.Username = user.Username;
                    newAccount.EmailId  = user.EmailId;
                    newAccount.Password = encrypt(user.Password);
                    db.UserAccounts.Add(newAccount);
                    db.SaveChanges();
                    return(true);
                }
            }
            return(false);
        }
示例#20
0
        public void ResetPassword(long?userid, UserAccountVM vm)
        {
            if (userid == null)
            {
                return;
            }
            var user = UserManager.FindById(userid.Value);

            if (user == null || vm == null || user.Email != vm.Email || user.SSID != vm.SSID ||
                user.PhoneNumber != vm.PhoneNumber)
            {
                return;
            }
            var random      = new Random();
            var newpassword = random.Next(100000, 999999);

            vm.Password = newpassword.ToString();
            vm.Id       = userid.Value;
            ChangePassword(vm);
            //*************** send sms with new code
        }
示例#21
0
 public IHttpActionResult RestPassword(UserAccountVM _user)
 {
     try
     {
         bool flag = repo.RestPassword(_user);
         if (flag)
         {
             return(Ok("Password has been reset "));
         }
         else
         {
             // dynamic response = new ExpandoObject();
             //response.message = "Password Can't be  reset";
             //return Content<UserAccountVM>(HttpStatusCode.BadRequest, response);
             return(BadRequest());
         }
     }catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
示例#22
0
 public IHttpActionResult CreateAccount(UserAccountVM user)
 {
     try
     {
         bool flag = repo.SignUp(user);
         if (flag)
         {
             return(Ok("User Created"));
         }
         else
         {
             dynamic response = new ExpandoObject();
             response.message = "User already exist";
             return(Content <UserAccountVM>(HttpStatusCode.BadRequest, response));
         }
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
示例#23
0
 public IHttpActionResult UserLogin(UserAccountVM user)
 {
     try
     {
         bool flag = repo.UserValidation(user);
         if (flag)
         {
             return(Ok("Valid User"));
         }
         else
         {
             //dynamic response = new ExpandoObject();
             //response.message = "Invalid User";
             //return Content<UserAccountVM>(HttpStatusCode.BadRequest, response);
             return(BadRequest());
         }
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
        /// <summary>
        /// William Clark
        /// Created: 2021/02/25
        ///
        /// Event handler for Window_Loaded event
        /// </summary>
        ///
        /// <remarks>
        /// </remarks>
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            // Check to see if the UserAccount access token is still set to the 'empty' UserAccount
            if (_user.UserAccountID == 0)
            {
                // The user has not properly authenticated, close window
                Close();
            }

            // Create the UserAccountVM from the authenticated user
            try
            {
                _userAccountVM = _userAccountManager.GetUserAccountVMByUserAccount(_user);
            }
            catch (Exception)
            {
                MessageBox.Show("Additional User Account information could not be loaded.");
            }
            txtUsername.Text      = _user.UserName;
            txtUsername.IsEnabled = false;
            SelectDashboard(_userAccountVM);
        }
        public async Task <IActionResult> Register(UserAccountVM user)
        {
            try
            {
                var result = await _userAccountService.CreateUser(user.FirstName, user.LastName, user.IdentificationNumber, user.Bank, user.BankAccountNumber, user.BankPin);

                //--> odavde ide redirekcija sa postavljenim pass-om na ChangePass sa userAcc modelom i setovanim passom!
                return(RedirectToAction("ChangePassword", new UserAccountChangePassVM()
                {
                    Id = user.Id
                }));
            }
            catch (NotValidParameterException e)
            {
                Logger.LogError(e, e.Message);
                return(RedirectToPage("Error"));
            }
            catch (Exception e)
            {
                Logger.LogError(e, e.Message);
                return(RedirectToPage("Error"));
            }
        }
示例#26
0
        public UserAccount UserAccountSet(UserAccountVM vm, ref IMDResponse res)
        {
            //--------- TBD check this account is allowed to be updated from this user.??
            if (vm == null)
            {
                return(null);
            }
            var uw = new UnitWork();

            if (vm.Password != null)
            {
                vm.PasswordHash = UserManager.PasswordHasher.HashPassword(vm.Password);
            }
            if (vm.Id == 0)
            {
                vm.IsEnabled     = 1;
                vm.SecurityStamp = Guid.NewGuid().ToString();
            }
            vm.IndustrialCities = DbHelper.ManyToMany <UserAccount, IndustrialCity>(uw, vm, x => x.IndustrialCities, vm.IndustrialCitiesIds, ref res);
            var us = uw.Command <UserAccount>().MapAndSaveDiff(vm, ref res);

            uw.Save(ref res);
            return(us);
        }
示例#27
0
        public bool SignUp(UserAccountVM user)
        {
            try
            {
                using (var client = new HttpClient())
                {
                    client.BaseAddress = new Uri("https://localhost:44393/api/UserAccount/");
                    var postTask = client.PostAsJsonAsync("CreateAccount", user);
                    postTask.Wait();

                    var result = postTask.Result;
                    if (result.IsSuccessStatusCode)
                    {
                        return(true);
                    }
                }
                return(false);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return(false);
            }
        }
示例#28
0
        public ActionResult SignUp(UserAccountVM user)
        {
            bool flag = false;

            if (!user.Password.Equals(user.ConfirmPassword))
            {
                ModelState.AddModelError("", "Password and Confirm Password Doesn't match");
                return(View());
            }
            else
            {
                flag = account.SignUp(user);
                if (flag)
                {
                    TempData["msg"] = 2;
                    return(RedirectToAction("Login"));
                }
                else
                {
                    ModelState.AddModelError("", " User Already Exits");
                    return(View());
                }
            }
        }
示例#29
0
        public void TestGetUserAccountVMByUserAccountReturnsUserAccountVM()
        {
            // Arrange
            UserAccountVM expectedUserAccount = new UserAccountVM(new UserAccount(1, "First", "Administrator", "firstAdmin", "*****@*****.**", true), new List <MembershipVM>()
            {
                new MembershipVM(1, 1, new List <Role>()
                {
                    new Role(1, "Admin", "User Administrator")
                })
            });
            UserAccountVM actualUserAccount;

            // Act
            actualUserAccount = _userAccountManager.GetUserAccountVMByUserAccount(expectedUserAccount);

            // Assert
            Assert.AreEqual(expectedUserAccount.UserAccountID, actualUserAccount.UserAccountID);
            Assert.AreEqual(expectedUserAccount.FirstName, actualUserAccount.FirstName);
            Assert.AreEqual(expectedUserAccount.LastName, actualUserAccount.LastName);
            Assert.AreEqual(expectedUserAccount.UserName, actualUserAccount.UserName);
            Assert.AreEqual(expectedUserAccount.Email, actualUserAccount.Email);
            Assert.AreEqual(expectedUserAccount.Active, actualUserAccount.Active);
            Assert.AreEqual(expectedUserAccount.Memberships.Count, actualUserAccount.Memberships.Count);
        }
示例#30
0
        public ActionResult RestCredential(UserAccountVM user)
        {
            bool flag = false;

            if (!user.Password.Equals(user.ConfirmPassword))
            {
                ModelState.AddModelError("", "Password and Confirm Password Doesn't match");
                return(View());
            }
            else
            {
                flag = account.RestPassword(user);
                if (flag)
                {
                    TempData["msg"] = 1;
                    return(RedirectToAction("Login"));
                }
                else
                {
                    ModelState.AddModelError("", "Please Register yourself,User doesn't exist or You are entering something wrong");
                    return(View());
                }
            }
        }