Files
LeafWeb/Web/Controllers/LeafInputController.cs
T
2016-01-29 11:25:44 -05:00

46 lines
1.0 KiB
C#

using System.IO;
using System.Linq;
using System.Web.Mvc;
using LeafWeb.Core.DAL;
using LeafWeb.Web.ViewModels.LeafInput;
namespace LeafWeb.Web.Controllers
{
public class LeafInputController : Controller
{
public ActionResult Index()
{
var dataService = new DataService();
var fluxnetSites = dataService.GetFluxnetSites().ToList();
// initialize the session storage to retain SessionID between requests
Session["placeholder"] = 0;
return View();
}
[HttpPost]
public ActionResult Index(CreateViewModel viewModel)
{
// directory name is the sessionID
var directory = Session.SessionID;
var path = Path.Combine(Server.MapPath("~/Files/"), directory + "\\");
var files = Directory.GetFiles(path);
if (!files.Any())
{
ModelState.AddModelError("", "Must select at least one file");
}
if (ModelState.IsValid)
{
// convert viewModel into Model
// load files into LeafInputFile
//
}
return View();
}
}
}