Beispiel #1
0
        public object Post(Users request)
        {
            if (!Utils.IsValidEmail(request.email))
            {
                return(new HttpError("User Not Saved. Correct email"));
            }

            string pass = request.password;

            if (!string.IsNullOrWhiteSpace(pass))
            {
                if (string.IsNullOrWhiteSpace(request.password_confirm) || !pass.Equals(request.password_confirm))
                {
                    return(new HttpError("Passwords do not match."));
                }
            }
            else
            {
                pass = bigWebApps.bigWebDesk.Data.Logins.GenerateRandomPassword();
            }

            ApiUser hdUser = request.ApiUser;
            //string global = "0";
            int _user_id  = 0;
            int _login_id = 0;
            int role      = !string.IsNullOrWhiteSpace(request.role) && request.role.ToLower().Equals("tech") ? (int)bigWebApps.bigWebDesk.UserAuth.UserRole.Technician : (int)bigWebApps.bigWebDesk.UserAuth.UserRole.StandardUser;

            bigWebApps.bigWebDesk.Data.Logins.VerifyLogin(hdUser.DepartmentId, request.email, ref _user_id, ref _login_id, hdUser.OrganizationId);

            if (string.IsNullOrWhiteSpace(request.firstname))
            {
                return(new HttpError("User Not Saved. Correct Firstname"));
            }
            if (string.IsNullOrWhiteSpace(request.lastname))
            {
                return(new HttpError("User Not Saved. Correct Lastname"));
            }

            if (_login_id == 0)
            {
                _login_id = bigWebApps.bigWebDesk.Data.Logins.UpdateLogin(hdUser.OrganizationId, hdUser.InstanceId, request.email, request.firstname, request.lastname, pass, "", role);
                _user_id  = bigWebApps.bigWebDesk.Data.Logins.InsertLoginCompanyJunc(hdUser.OrganizationId, hdUser.DepartmentId, _login_id, role);
            }
            else
            {
                if (_user_id == -1)
                {
                    _user_id = bigWebApps.bigWebDesk.Data.Logins.InsertLoginCompanyJunc(hdUser.OrganizationId, hdUser.DepartmentId, _login_id, role);
                }
                if (_user_id > 0)
                {
                    return(new HttpError("This login/email is already in use for this department/organization."));
                }
            }
            if (_login_id > 0 && _user_id > 0)
            {
                return(UserAccounts.GetUser(hdUser.OrganizationId, hdUser.DepartmentId, _user_id));
            }
            return(new HttpResult(HttpStatusCode.NotFound, "Can't find selected login. Maybe this login was deleted by another user."));
        }
Beispiel #2
0
        public object Any(Users request)
        {
            ApiUser hdUser = request.ApiUser;

            if (request.id > 0)
            {
                return(UserAccounts.GetUser(hdUser.OrganizationId, hdUser.DepartmentId, request.id));
            }
            return(UserAccounts.FindUsers(hdUser.OrganizationId, hdUser.DepartmentId, hdUser.UserId, request.firstname, request.lastname, request.email, request.page, request.limit));
        }
Beispiel #3
0
        private object GetUsers(Users request)
        {
            ApiUser hdUser = request.ApiUser;

            if (request.id > 0)
            {
                return(UserAccounts.GetUser(hdUser.OrganizationId, hdUser.DepartmentId, request.id));
            }
            var _cfg = new bigWebApps.bigWebDesk.Config(hdUser.OrganizationId, hdUser.InstanceId);

            //v3
            //if (!string.IsNullOrEmpty(request.query))
            //{
            //    request.search = request.query;
            //}
            return(request.FilteredResult <UserAccount>(UserAccounts.FindUsers(hdUser.OrganizationId, hdUser.DepartmentId, hdUser.UserId, _cfg.AccountManager, _cfg.LocationTracking, request.search, request.firstname, request.lastname, request.email, request.role, _cfg.UnassignedQue)));
        }