コード例 #1
0
        public ActionResult <ItemResponse <Paged <ProviderNonCompliant> > > SelectAllNonCompliant(int pageIndex, int pageSize)
        {
            int          code     = 200;
            BaseResponse response = null;

            try
            {
                IUserAuthData user = _auth.GetCurrentUser();
                Paged <ProviderNonCompliant> pagedItems = null;
                if (user.Roles.Contains("SysAdmin") || user.Roles.Contains("Office Manager"))
                {
                    if (user.Roles.Contains("SysAdmin"))
                    {
                        pagedItems = _service.SelectAllNonCompliant(pageIndex, pageSize);
                    }
                    else
                    {
                        pagedItems = _service.SelectNonCompliant(pageIndex, pageSize, user.Id);
                    }
                }

                if (pagedItems == null)
                {
                    code     = 404;
                    response = new ErrorResponse("App resource not found.");
                }
                else
                {
                    response = new ItemResponse <Paged <ProviderNonCompliant> > {
                        Item = pagedItems
                    };
                }
            }
            catch (Exception ex)
            {
                base.Logger.LogError(ex.ToString());
                code     = 500;
                response = new ErrorResponse(ex.Message);
            }

            return(StatusCode(code, response));
        }