Add Photosynthesis Type
This commit is contained in:
@@ -5,6 +5,7 @@ using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using LeafWeb.Core.Models;
|
||||
using LeafWeb.Web.Attributes;
|
||||
using LeafWeb.Web.ViewModels;
|
||||
using LeafWeb.Web.ViewModels.LeafInput;
|
||||
|
||||
namespace LeafWeb.Web.Controllers
|
||||
@@ -15,25 +16,9 @@ namespace LeafWeb.Web.Controllers
|
||||
{
|
||||
// initialize the session storage to retain SessionID between requests
|
||||
Session["placeholder"] = 0;
|
||||
return View();
|
||||
}
|
||||
|
||||
private FileInfo[] GetBackloadDirectoryFiles(string directoryName)
|
||||
{
|
||||
var path = Path.Combine(Server.MapPath("~/Files/"), directoryName + "\\");
|
||||
var directory = new DirectoryInfo(path);
|
||||
return
|
||||
!directory.Exists
|
||||
? new FileInfo[] {}
|
||||
: directory.GetFiles();
|
||||
}
|
||||
|
||||
private void DeleteBackloadDirectory(string directoryName)
|
||||
{
|
||||
var path = Path.Combine(Server.MapPath("~/Files/"), directoryName + "\\");
|
||||
var directory = new DirectoryInfo(path);
|
||||
if (directory.Exists)
|
||||
directory.Delete(true);
|
||||
var viewModel = new CreateViewModel();
|
||||
HydrateCreateViewModel(viewModel);
|
||||
return View(viewModel);
|
||||
}
|
||||
|
||||
[HttpParamAction]
|
||||
@@ -50,9 +35,21 @@ namespace LeafWeb.Web.Controllers
|
||||
{
|
||||
// Go to confirmation
|
||||
var confirmViewModel = new ConfirmViewModel(viewModel, files.Select(f => f.Name).ToArray());
|
||||
HydrateCreateViewModel(confirmViewModel);
|
||||
|
||||
return View("Confirm", confirmViewModel);
|
||||
}
|
||||
return View("Index");
|
||||
|
||||
HydrateCreateViewModel(viewModel);
|
||||
return View("Index", viewModel);
|
||||
}
|
||||
|
||||
private void HydrateCreateViewModel(dynamic viewModel)
|
||||
{
|
||||
if (viewModel.PhotosynthesisType == null)
|
||||
viewModel.PhotosynthesisType = new SelectListViewModel();
|
||||
if (viewModel.PhotosynthesisType.ListItems == null)
|
||||
viewModel.PhotosynthesisType.ListItems = GetPhotosynthesisTypeSelectList();
|
||||
}
|
||||
|
||||
[HttpParamAction]
|
||||
@@ -70,7 +67,7 @@ namespace LeafWeb.Web.Controllers
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
// convert viewModel into Model
|
||||
var leafInput = viewModel.GetFileInput();
|
||||
var leafInput = viewModel.GetFileInput(DataService);
|
||||
// load files into LeafInputFile
|
||||
leafInput.LeafInputFiles =
|
||||
(from f in files
|
||||
@@ -89,7 +86,27 @@ namespace LeafWeb.Web.Controllers
|
||||
StatusType.Success);
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
|
||||
HydrateCreateViewModel(viewModel);
|
||||
return View("Index", viewModel);
|
||||
}
|
||||
|
||||
private FileInfo[] GetBackloadDirectoryFiles(string directoryName)
|
||||
{
|
||||
var path = Path.Combine(Server.MapPath("~/Files/"), directoryName + "\\");
|
||||
var directory = new DirectoryInfo(path);
|
||||
return
|
||||
!directory.Exists
|
||||
? new FileInfo[] { }
|
||||
: directory.GetFiles();
|
||||
}
|
||||
|
||||
private void DeleteBackloadDirectory(string directoryName)
|
||||
{
|
||||
var path = Path.Combine(Server.MapPath("~/Files/"), directoryName + "\\");
|
||||
var directory = new DirectoryInfo(path);
|
||||
if (directory.Exists)
|
||||
directory.Delete(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user