public ActionResult AddAUser(user newUser)
        {
            HashPassword newPassword = new HashPassword();

            if (ModelState.IsValid)
            {
                newUser.password     = newPassword.createHashedPassword(newUser.password);
                newUser.passwordSalt = newPassword.salt;
                db.users.Add(newUser);
                db.SaveChanges();
            }
            ViewBag.role = loadUserRoles();
            return(View(newUser));
        }
        public bool AddANewUser(UserDetailsToAddOrUpdate UserDetailsSubmitted)
        {
            try
            {
                HashPasswordObject = new HashPassword();
                User NewUser = new User();
                NewUser.firstName            = UserDetailsSubmitted.firstName;
                NewUser.lastName             = UserDetailsSubmitted.lastName;
                NewUser.email                = UserDetailsSubmitted.email;
                NewUser.phoneNumber          = UserDetailsSubmitted.phoneNumber;
                NewUser.dateTimeCreated      = DateTime.Now;
                NewUser.userSubscriptionType = Convert.ToInt32(UserDetailsSubmitted.userSubscriptionType);
                NewUser.password             = HashPasswordObject.createHashedPassword(UserDetailsSubmitted.password);
                NewUser.passwordSalt         = HashPasswordObject.salt;
                NewUser.accountState         = getFieldStateID("Activated");
                NewUser.userType             = Convert.ToInt32(UserDetailsSubmitted.userRoleForUser);

                UserSubscription registerUserSubscription = new UserSubscription();
                registerUserSubscription.userID          = NewUser.userID;
                registerUserSubscription.startDate       = DateTime.Now;
                registerUserSubscription.endDate         = new DateTime(2019, 3, 09);
                registerUserSubscription.state           = getFieldStateID("Activated");
                registerUserSubscription.subcriptionType = Convert.ToInt32(UserDetailsSubmitted.userSubscriptionType);
                TipezeNyumbaServiceUnitOfWork.Repository <User>().Add(NewUser);
                TipezeNyumbaServiceUnitOfWork.Repository <UserSubscription>().Add(registerUserSubscription);
                TipezeNyumbaServiceUnitOfWork.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                string message = ex.Message;
                return(false);

                throw;
            }
        }