init
This commit is contained in:
commit
e124a47765
19374 changed files with 9806149 additions and 0 deletions
|
@ -0,0 +1,74 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using Kreta.BusinessLogic.HelperClasses;
|
||||
using Kreta.BusinessLogic.Helpers;
|
||||
using Kreta.BusinessLogic.Interfaces;
|
||||
using Kreta.Resources;
|
||||
using Kreta.Web.Areas.DualisKepzes.Models;
|
||||
using Kreta.Web.Helpers;
|
||||
using Kreta.Web.Helpers.Error;
|
||||
using Kreta.Web.ModelBinder.Mvc;
|
||||
using Kreta.Web.Security;
|
||||
|
||||
namespace Kreta.Web.Areas.DualisKepzes.Controllers
|
||||
{
|
||||
public abstract class BaseDualisSzerzodesController : Controller
|
||||
{
|
||||
private readonly IFileServiceHelper _fileServiceHelper;
|
||||
|
||||
public BaseDualisSzerzodesController(IFileServiceHelper fileServiceHelper)
|
||||
{
|
||||
_fileServiceHelper = fileServiceHelper ?? throw new ArgumentNullException(nameof(fileServiceHelper));
|
||||
}
|
||||
|
||||
public ActionResult Index()
|
||||
{
|
||||
return View("Index");
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public ActionResult UploadFile([ModelBinder(typeof(AlapdokumentumFileUploadBinder))] IEnumerable<System.Web.HttpPostedFileBase> files, int tanuloId)
|
||||
{
|
||||
if (files != null && files.Any())
|
||||
{
|
||||
var uploadedFiles = files.ToList();
|
||||
var helper = new DualisSzerzodesHelper(ConnectionTypeExtensions.GetSessionConnectionType(), _fileServiceHelper);
|
||||
helper.Upload(uploadedFiles[0], ClaimData.IntezmenyGuid.Value, tanuloId);
|
||||
}
|
||||
|
||||
return Content("");
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public HttpResponseMessage DeleteFile(int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
new DualisSzerzodesHelper(ConnectionTypeExtensions.GetSessionConnectionType(), _fileServiceHelper).SetFelhasznaloAltalTorolt(id);
|
||||
return new HttpResponseMessage(HttpStatusCode.OK);
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw new StatusError(HttpStatusCode.BadRequest, ErrorResource.HibaATorlesSoran);
|
||||
}
|
||||
}
|
||||
|
||||
public ActionResult DownloadFile(FormCollection form)
|
||||
{
|
||||
var fileId = form["FileIdHiddenField"];
|
||||
|
||||
var helper = new DualisSzerzodesHelper(ConnectionTypeExtensions.GetSessionConnectionType(), _fileServiceHelper);
|
||||
|
||||
var (fajlnev, tartalom) = helper.GetFileData(int.Parse(fileId));
|
||||
var stream = new MemoryStream(tartalom);
|
||||
var result = File(stream, MimeMapping.GetMimeMapping(fajlnev), fajlnev);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue