Exemplo n.º 1
0
        public string Update(UserManagerVm data)
        {
            if (!ModelState.IsValid)
            {
                return(PostReturnVals.Failed);
            }

            var resp = RestUnitOfWork.UserMgrSvc.Update(CurrentUserProviderToken, data);

            if (resp.IsSuccess)
            {
                return(PostReturnVals.Success);
            }

            return(resp.Message);
        }
Exemplo n.º 2
0
        public ActionResult ManagerDashboard(string id)
        {
            /* DEV NOTE: Grab the first user owned manager if the
             * id is not supplied, but if the id has value
             * then grab that specific manager to be display
             * in the dashboard.
             * --------------------------------------*/
            var           resp           = RestUnitOfWork.UserMgrSvc.GetList(CurrentUserProviderToken);
            UserManagerVm currentManager = null;

            if (!string.IsNullOrWhiteSpace(id))
            {
                currentManager = resp.Managers?.FirstOrDefault(f => f.Identity == id);
            }
            else
            {
                currentManager = resp.Managers?.FirstOrDefault();
            }

            var model = new Tuple <IEnumerable <UserManagerVm>, UserManagerVm>(resp.Managers, currentManager);

            return(View("ManagerDashboard", model));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Update an existing User Manager.
        /// </summary>
        /// <param name="loginProviderKey">Login Provider Key</param>
        /// <param name="manager">User Manager View Model</param>
        /// <returns><![CDATA[ (UserManagerVm Manager, bool IsSuccess, string Message) ]]></returns>
        public (UserManagerVm Manager, bool IsSuccess, string Message) Update(string loginProviderKey, UserManagerVm manager, MemberManagerStatus?status = null)
        {
            if (string.IsNullOrWhiteSpace(manager.Name))
            {
                return(null, false, "Manager name length must have atleast 1 character in it.");
            }

            /* DEV NOTE : Make sure that the member manager exists in the server database
             *            before even doing the update, this also block the users from
             *            from setting the status when the status is on PENDING
             * ---------------------------------------------------------------------*/
            var servManager = Get(loginProviderKey, manager.Identity);

            if (servManager.Manager == null)
            {
                return(manager, false, MemberManagerMessages.Error.MANAGER_DOES_NOT_EXISTS);
            }

            if (servManager.Manager.Settings.Status == MemberManagerStatus.Pending ||
                servManager.Manager.Settings.Status == MemberManagerStatus.Banned)
            {
                manager.Settings.Status = servManager.Manager.Settings.Status;
            }

            // This will be an admin overriding the status of the manager to make it active or otherwise
            // un-ban the manager form the server.
            if (status != null)
            {
                manager.Settings.Status = (MemberManagerStatus)status;
            }

            var resp = Put <UserManagerVm>(string.Format(API_MEMBER_MANAGER_BASE, loginProviderKey) + "UpdateManager",
                                           new
            {
                Identity = manager.Identity,
                Name     = manager.Name,
                Settings = manager.Settings
            });

            return(resp.Response, resp.IsSuccess, resp.Message);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Create a new User Manager
        /// </summary>
        /// <param name="loginProviderKey">Login Provider Key</param>
        /// <param name="manager">User Manager View Model</param
        /// <param name="status">ADMIN OVERRIDE : Status</param>
        /// <returns><![CDATA[ (UserManagerVm Manager, bool IsSuccess, string Message) ]]></returns>
        public (UserManagerVm Manager, bool IsSuccess, string Message) Create(string loginProviderKey, UserManagerVm manager)
        {
            if (string.IsNullOrWhiteSpace(manager.Name))
            {
                return(null, false, "Manager name length must have atleast 1 character in it.");
            }

            var resp = Post <UserManagerVm>(string.Format(API_MEMBER_MANAGER_BASE, loginProviderKey) + "CreateManager",
                                            new
            {
                Name     = manager.Name,
                Settings = manager.Settings
            });

            return(resp.Response, resp.IsSuccess, resp.Message);
        }