コード例 #1
0
        public FileStreamResult ReportSelectAll(ProviderDetailCategories categories)
        {
            BaseResponse response;

            try
            {
                IUserAuthData user   = _auth.GetCurrentUser();
                MemoryStream  stream = null;
                if (user.Roles.Contains("Office Manager") || (user.Roles.Contains("SysAdmin")))
                {
                    if (user.Roles.Contains("SysAdmin"))
                    {
                        stream = _service.ReportSelectAll(categories, 0);
                    }
                    else
                    {
                        stream = _service.ReportSelectAll(categories, user.Id);
                    }
                }


                if (stream == null)
                {
                    response = new ErrorResponse("App resource not found.");
                }
                else
                {
                    stream.Position = 0;
                    var contentType = "application/octet-stream";
                    var fileName    = "ProviderReport.xlsx";
                    return(File(stream, contentType, fileName));
                }
            }
            catch (Exception ex)
            {
                base.Logger.LogError(ex.ToString());

                response = new ErrorResponse(ex.Message);
            }
            return(null);
        }