using Backload.Contracts.Context;
using Backload.Contracts.FileHandler;
using Backload.Helper;
using System.Net;
using System.Threading.Tasks;
using System.Web;
using System.Web.Mvc;
namespace Backload.Controllers
{
///
/// The integrated controller to handle file requests.
/// You can remove this code, if you have a custom controller or handler.
///
public partial class BackloadController : Controller
{
///
/// The Backload file handler.
/// To access it in an Javascript ajax request use: var url = "/{Application}/Backload/FileHandler/";.
///
[AcceptVerbs(HttpVerbs.Get|HttpVerbs.Post|HttpVerbs.Put|HttpVerbs.Delete|HttpVerbs.Options)]
public async Task FileHandler()
{
try
{
// Create and initialize the handler
IFileHandler handler = Backload.FileHandler.Create();
handler.Init(HttpContext.Request);
// Call the execution pipeline and get the result
IBackloadResult result = await handler.Execute();
// Helper to create an ActionResult object from the IBackloadResult instance
return ResultCreator.Create(result);
}
catch
{
return new HttpStatusCodeResult(HttpStatusCode.InternalServerError);
}
}
}
}