| | |
| | | [Authorize, ApiController] |
| | | public class ApiBaseController<IService, TEntity> : Controller |
| | | { |
| | | protected IService Service; |
| | | protected readonly IService Service; |
| | | |
| | | public ApiBaseController(IService service) |
| | | { |
| | | Service = service; |
| | | Service = service ?? throw new ArgumentNullException(nameof(service)); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | [HttpPost, Route("Export")] |
| | | public virtual ActionResult Export([FromBody] PageDataOptions loadData) |
| | | { |
| | | WebResponseContent result = InvokeService("Export", new object[] { loadData }) as WebResponseContent; |
| | | if (result.Status) |
| | | WebResponseContent? result = InvokeService("Export", new object[] { loadData }) as WebResponseContent; |
| | | if (result != null && result.Status && result.Data != null) |
| | | return File( |
| | | System.IO.File.ReadAllBytes(result.Data.ToString()), |
| | | System.IO.File.ReadAllBytes(result.Data.ToString() ?? string.Empty), |
| | | System.Net.Mime.MediaTypeNames.Application.Octet, |
| | | Path.GetFileName(result.Data.ToString()) |
| | | Path.GetFileName(result.Data.ToString() ?? string.Empty) ?? string.Empty |
| | | ); |
| | | return Json(result); |
| | | } |
| | |
| | | [HttpPost, HttpGet, Route("DownLoadTemplate")] |
| | | public virtual ActionResult DownLoadTemplate() |
| | | { |
| | | WebResponseContent result = InvokeService("DownLoadTemplate", new object[] { }) as WebResponseContent; |
| | | if (result.Status) |
| | | WebResponseContent? result = InvokeService("DownLoadTemplate", new object[] { }) as WebResponseContent; |
| | | if (result != null && result.Status && result.Data != null) |
| | | return File( |
| | | System.IO.File.ReadAllBytes(result.Data.ToString()), |
| | | System.IO.File.ReadAllBytes(result.Data.ToString() ?? string.Empty), |
| | | System.Net.Mime.MediaTypeNames.Application.Octet, |
| | | Path.GetFileName(result.Data.ToString()) |
| | | Path.GetFileName(result.Data.ToString() ?? string.Empty) ?? string.Empty |
| | | ); |
| | | return Json(result); |
| | | } |