Add LeafInput

Add EntityFramework
This commit is contained in:
2016-11-16 11:22:53 -05:00
parent 15911f33c0
commit 88a21593da
14 changed files with 483 additions and 417 deletions
+1 -36
View File
@@ -8,7 +8,7 @@ using Umbraco.Web;
using Umbraco.ModelsBuilder;
using Umbraco.ModelsBuilder.Umbraco;
[assembly: PureLiveAssembly]
[assembly:ModelsBuilderAssembly(PureLive = true, SourceHash = "508a57e7748cbe2")]
[assembly:ModelsBuilderAssembly(PureLive = true, SourceHash = "a97af64e5fffa72c")]
[assembly:System.Reflection.AssemblyVersion("0.0.0.1")]
@@ -260,41 +260,6 @@ namespace Umbraco.Web.PublishedContentModels
}
}
/// <summary>Leaf Input</summary>
[PublishedContentModel("TextPage1")]
public partial class TextPage1 : PublishedContentModel
{
#pragma warning disable 0109 // new is redundant
public new const string ModelTypeAlias = "TextPage1";
public new const PublishedItemType ModelItemType = PublishedItemType.Content;
#pragma warning restore 0109
public TextPage1(IPublishedContent content)
: base(content)
{ }
#pragma warning disable 0109 // new is redundant
public new static PublishedContentType GetModelContentType()
{
return PublishedContentType.Get(ModelItemType, ModelTypeAlias);
}
#pragma warning restore 0109
public static PublishedPropertyType GetModelPropertyType<TValue>(Expression<Func<TextPage1, TValue>> selector)
{
return PublishedContentModelUtility.GetModelPropertyType(GetModelContentType(), selector);
}
///<summary>
/// Content
///</summary>
[ImplementPropertyType("content")]
public Newtonsoft.Json.Linq.JToken Content
{
get { return this.GetPropertyValue<Newtonsoft.Json.Linq.JToken>("content"); }
}
}
/// <summary>Folder</summary>
[PublishedContentModel("Folder")]
public partial class Folder : PublishedContentModel
+1 -36
View File
@@ -19,7 +19,7 @@ using Umbraco.ModelsBuilder;
using Umbraco.ModelsBuilder.Umbraco;
[assembly: PureLiveAssembly]
[assembly:ModelsBuilderAssembly(PureLive = true, SourceHash = "508a57e7748cbe2")]
[assembly:ModelsBuilderAssembly(PureLive = true, SourceHash = "a97af64e5fffa72c")]
[assembly:System.Reflection.AssemblyVersion("0.0.0.2")]
namespace Umbraco.Web.PublishedContentModels
@@ -244,41 +244,6 @@ namespace Umbraco.Web.PublishedContentModels
}
}
/// <summary>Leaf Input</summary>
[PublishedContentModel("TextPage1")]
public partial class TextPage1 : PublishedContentModel
{
#pragma warning disable 0109 // new is redundant
public new const string ModelTypeAlias = "TextPage1";
public new const PublishedItemType ModelItemType = PublishedItemType.Content;
#pragma warning restore 0109
public TextPage1(IPublishedContent content)
: base(content)
{ }
#pragma warning disable 0109 // new is redundant
public new static PublishedContentType GetModelContentType()
{
return PublishedContentType.Get(ModelItemType, ModelTypeAlias);
}
#pragma warning restore 0109
public static PublishedPropertyType GetModelPropertyType<TValue>(Expression<Func<TextPage1, TValue>> selector)
{
return PublishedContentModelUtility.GetModelPropertyType(GetModelContentType(), selector);
}
///<summary>
/// Content
///</summary>
[ImplementPropertyType("content")]
public Newtonsoft.Json.Linq.JToken Content
{
get { return this.GetPropertyValue<Newtonsoft.Json.Linq.JToken>("content"); }
}
}
/// <summary>Folder</summary>
[PublishedContentModel("Folder")]
public partial class Folder : PublishedContentModel
+1 -1
View File
@@ -1 +1 @@
508a57e7748cbe2
a97af64e5fffa72c
+19
View File
@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using LeafWeb.Core.DAL;
using Umbraco.Core;
namespace WebCms.App_Start
{
public class RegisterDataService : ApplicationEventHandler
{
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
DataService.RegisterInitializer();
base.ApplicationStarted(umbracoApplication, applicationContext);
}
}
}
+70
View File
@@ -0,0 +1,70 @@
using System;
using System.Linq;
using System.Web.Mvc;
using log4net;
using LeafWeb.Core.DAL;
using Umbraco.Web.Mvc;
namespace WebCms.Controllers
{
public class BaseController : SurfaceController
{
protected readonly DataService DataService = new DataService();
protected override void Dispose(bool disposing)
{
DataService.Dispose();
base.Dispose(disposing);
}
protected override void OnException(ExceptionContext filterContext)
{
if (filterContext?.Exception != null)
{
var controller = filterContext.RouteData.Values["controller"].ToString();
var action = filterContext.RouteData.Values["action"].ToString();
var loggerName = $"{controller}Controller.{action}";
LogManager.GetLogger(loggerName).Error(filterContext.Exception);
}
base.OnException(filterContext);
}
protected bool IsHttpParamActionMatch()
{
return ControllerContext.RouteData.Values["action"].ToString()
.Equals("Action", StringComparison.InvariantCultureIgnoreCase);
}
protected enum StatusType
{
Info,
Success,
Error
}
protected void SetStatusMessage(string msg, StatusType statusType = StatusType.Info)
{
TempData["StatusMessage"] = msg;
switch (statusType)
{
case StatusType.Success:
TempData["StatusMessage-Type"] = "alert-success";
break;
case StatusType.Error:
TempData["StatusMessage-Type"] = "alert-error";
break;
case StatusType.Info:
break;
default:
throw new ArgumentOutOfRangeException(nameof(statusType), statusType, null);
}
}
protected SelectList GetPhotosynthesisTypeSelectList()
{
return new SelectList(DataService.GetPhotosynthesisTypes().ToList(), "Id", "Name");
}
}
}
+40 -4
View File
@@ -1,13 +1,49 @@
using System.Web.Mvc;
using Umbraco.Web.Mvc;
using WebCms.Models;
namespace WebCms.Controllers
{
public class LeafInputController : SurfaceController
public class LeafInputController : BaseController
{
public ActionResult Index()
public ActionResult Create()
{
return View();
var viewModel = new LeafInputCreate();
HydrateCreateViewModel(viewModel);
return PartialView(viewModel);
}
//[HttpParamAction]
[HttpPost]
public ActionResult Submit(LeafInputCreate viewModel)
{
if (!ModelState.IsValid)
return CurrentUmbracoPage();
// directory name is the sessionID
//var files = GetBackloadDirectoryFiles(Session.SessionID);
//if (!files.Any())
// ModelState.AddModelError("Files", "Must select at least one file");
//if (ModelState.IsValid && !IsHttpParamActionMatch()) // HttpParamMatch indicates it's backing out from Confirm
//{
// // Go to confirmation
// var confirmViewModel = new ConfirmViewModel(viewModel, files.Select(f => f.Name).ToArray());
// HydrateCreateViewModel(confirmViewModel);
// return View("Confirm", confirmViewModel);
//}
HydrateCreateViewModel(viewModel);
return CurrentUmbracoPage();
}
private void HydrateCreateViewModel(dynamic viewModel)
{
if (viewModel.PhotosynthesisType == null)
viewModel.PhotosynthesisType = new SelectListViewModel();
if (viewModel.PhotosynthesisType.ListItems == null)
viewModel.PhotosynthesisType.ListItems = GetPhotosynthesisTypeSelectList();
}
}
}
+16 -5
View File
@@ -1,5 +1,8 @@
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using AutoMapper;
using Umbraco.Core.Models;
using Umbraco.Web.Models;
namespace WebCms.Models
{
@@ -22,10 +25,18 @@ namespace WebCms.Models
Mapper.CreateMap<LeafInputCreate, LeafInputConfirm>();
}
public LeafInputConfirm(LeafInputCreate leafInputCreate, string[] files)
{
Mapper.Map(leafInputCreate, this);
Files = files;
}
//public LeafInputConfirm(LeafInputCreate leafInputCreate, string[] files)
//{
// Mapper.Map(leafInputCreate, this);
// Files = files;
//}
//public LeafInputConfirm(IPublishedContent content, CultureInfo culture) : base(content, culture)
//{
//}
//public LeafInputConfirm(IPublishedContent content) : base(content)
//{
//}
}
}
+24 -18
View File
@@ -1,6 +1,9 @@
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using AutoMapper;
using LeafWeb.Core.DAL;
using Umbraco.Core.Models;
using Umbraco.Web.Models;
namespace WebCms.Models
{
@@ -11,24 +14,24 @@ namespace WebCms.Models
[RegularExpression(@"[A-Za-z().]+(\s+[A-Za-z().]+)+", ErrorMessage = "Please provide your full name")]
public string Name { get; set; }
[Display(Name = "Your email address")]
[Required(ErrorMessage = "An email address is required")]
[DataType(DataType.EmailAddress)]
[RegularExpression(@"[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}", ErrorMessage = "Must be an email address")]
public string Email { get; set; }
//[Display(Name = "Your email address")]
//[Required(ErrorMessage = "An email address is required")]
//[DataType(DataType.EmailAddress)]
//[RegularExpression(@"[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}", ErrorMessage = "Must be an email address")]
//public string Email { get; set; }
[Display(Name = "Confirm email address")]
[Required(ErrorMessage = "Enter email exactly as above")]
[Compare("Email")]
public string EmailConfirm { get; set; }
//[Display(Name = "Confirm email address")]
//[Required(ErrorMessage = "Enter email exactly as above")]
//[Compare("Email")]
//public string EmailConfirm { get; set; }
[Display(Name = "A unique identifier for this data")]
[Required(ErrorMessage = "A unique identifier is required")]
public string Identifier { get; set; }
//[Display(Name = "A unique identifier for this data")]
//[Required(ErrorMessage = "A unique identifier is required")]
//public string Identifier { get; set; }
[Display(Name = "The site's name/Fluxnet ID, if known")]
[Required(ErrorMessage = "The site's name is required")]
public string SiteId { get; set; }
//[Display(Name = "The site's name/Fluxnet ID, if known")]
//[Required(ErrorMessage = "The site's name is required")]
//public string SiteId { get; set; }
[Display(Name = "Photosynthetic Pathways")]
[Required(ErrorMessage = "A Photosynthetic pathway must be chosen")]
@@ -40,13 +43,16 @@ namespace WebCms.Models
.ForMember(dest => dest.PhotosynthesisType, opt => opt.Ignore());
}
public LeafWeb.Core.Entities.LeafInput GetFileInput(DataService db)
public LeafInputCreate()
{
//PhotosynthesisType = new SelectListViewModel();
}
public LeafWeb.Core.Entities.LeafInput GetFileInput()
{
var leafInput = new LeafWeb.Core.Entities.LeafInput();
Mapper.Map(this, leafInput);
leafInput.PhotosynthesisType = db.GetPhotosynthesisType(PhotosynthesisType.Selected);
return leafInput;
}
}
-9
View File
@@ -1,9 +0,0 @@
@inherits UmbracoTemplatePage
@{
Layout = "Master.cshtml";
}
@CurrentPage.GetGridHtml("content", "fanoe")
@section Form{
@Html.Action("Index", "LeafInput")
}
@@ -1,51 +1,17 @@
@inherits UmbracoViewPage<WebCms.Models.LeafInputCreate>
@model WebCms.Models.LeafInputCreate
<div class="container">
<div class="row">
<div class="col-md-7 well">
@Html.Partial("_ValidationSummary")
<!-- The file upload form used as target for the file upload widget -->
<form id="fileupload" action="/Backload/FileHandler" method="POST" enctype="multipart/form-data">
<label class="control-label">Files</label>
<!-- The fileupload-buttonbar contains buttons to add/delete files and start/cancel the upload -->
<div class="row fileupload-buttonbar">
<div class="col-lg-5">
<!-- The fileinput-button span is used to style the file input field as button -->
<span class="btn btn-default fileinput-button">
<i class="glyphicon glyphicon-plus"></i>
<span>Add files...</span>
<input type="file" name="files[]" multiple>
</span>
<button type="button" class="btn btn-default delete">
<i class="glyphicon glyphicon-trash"></i>
<span>Delete</span>
</button>
<input type="checkbox" class="toggle">
<!-- The global file processing state -->
<span class="fileupload-process"></span>
</div>
<!-- The global progress state -->
<div class="col-lg-7 fileupload-progress fade">
<!-- The global progress bar -->
<div class="progress progress-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100">
<div class="progress-bar progress-bar-success" style="width: 0%;"></div>
</div>
<!-- The extended global progress state -->
@*<div class="progress-extended">&nbsp;</div>*@
</div>
</div>
@Html.Partial("_ValidationField", "Files")
<!-- The table listing the files available for upload/download -->
<table role="presentation" class="table table-striped panel panel-default"><tbody class="files"></tbody></table>
</form>
@using (Html.BeginForm("Index", "LeafInput", FormMethod.Post))
@using (Html.BeginUmbracoForm("Submit", "LeafInput", FormMethod.Post))
{
//@Html.EditorFor(m => m.PhotosynthesisType)
@Html.EditorFor(m => m.Identifier)
@Html.EditorFor(m => m.SiteId)
@Html.EditorFor(m => m.PhotosynthesisType)
@*@Html.EditorFor(m => m.Identifier)
@Html.EditorFor(m => m.SiteId)*@
@Html.EditorFor(m => m.Name)
@Html.EditorFor(m => m.Email)
@Html.EditorFor(m => m.EmailConfirm)
@*@Html.EditorFor(m => m.Email)
@Html.EditorFor(m => m.EmailConfirm)*@
<input type="submit" id="submit-form" class="hidden" />}
<label for="submit-form" class="btn btn-primary pull-right">Submit...</label>
</div>
@@ -0,0 +1,5 @@
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@{
Html.RenderAction("Create", "LeafInput");
}
+21 -1
View File
@@ -1,4 +1,4 @@
<?xml version="1.0"?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="urlrewritingnet" restartOnExternalChanges="true" requirePermission="false" type="UrlRewritingNet.Configuration.UrlRewriteSection, UrlRewritingNet.UrlRewriter" />
@@ -13,6 +13,8 @@
<section name="FileSystemProviders" type="Umbraco.Core.Configuration.FileSystemProvidersSection, Umbraco.Core" requirePermission="false" />
<section name="dashBoard" type="Umbraco.Core.Configuration.Dashboard.DashboardSection, Umbraco.Core" requirePermission="false" />
</sectionGroup>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<umbracoConfiguration>
<settings configSource="config\umbracoSettings.config" />
@@ -48,11 +50,23 @@
<add key="owin:appStartup" value="UmbracoDefaultOwinStartup" />
<add key="Umbraco.ModelsBuilder.Enable" value="true" />
<add key="Umbraco.ModelsBuilder.ModelsMode" value="PureLive" />
<add key="EmailFromAddress" value="LeafWeb &lt;noreply@leafweb.org&gt;" />
<add key="AdminEmailAddresses" value="kolpacksoftware@gmail.com" />
<add key="ProcessQueueInterval" value="*/1 * * * *" />
<add key="SmtpHost" value="localhost" />
<add key="SmtpPort" value="25" />
<add key="SmtpUserName" value="" />
<add key="SmtpPassword" value="" />
<add key="LeafWebUrl" value="http://192.168.1.133:1640/" />
<add key="PiscalNotifyCompleteUrlPath" value="LeafInput/NotifyComplete" />
<add key="ResultsDownloadPath" value="Results/Download?token={0}" />
</appSettings>
<connectionStrings>
<remove name="umbracoDbDSN" />
<add name="umbracoDbDSN" connectionString="Server=tcp:leafweb.database.windows.net,1433;Database=leafwebUmbraco;User ID=lwadmin@leafweb;Password='j4f1a2e!'" providerName="System.Data.SqlClient" />
<!-- Important: If you're upgrading Umbraco, do not clear the connection string / provider name during your web.config merge. -->
<add name="LeafWebContext" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=LeafWeb;Integrated Security=True;Connect Timeout=60" providerName="System.Data.SqlClient" />
</connectionStrings>
<system.data>
<DbProviderFactories>
@@ -402,4 +416,10 @@
<urlCompression doStaticCompression="false" doDynamicCompression="false" dynamicCompressionBeforeCache="false" />
</system.webServer>
</location>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
</configuration>
+13 -2
View File
@@ -76,6 +76,14 @@
<HintPath>..\packages\xmlrpcnet.2.5.0\lib\net20\CookComputing.XmlRpcV2.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.SqlServer.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Examine, Version=0.1.70.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Examine.0.1.70.0\lib\Examine.dll</HintPath>
<Private>True</Private>
@@ -337,8 +345,7 @@
<Content Include="Views\Partials\Grid\Fanoe.cshtml" />
<Content Include="Views\Partials\MainNavigation.cshtml" />
<Content Include="Views\TextPage.cshtml" />
<Content Include="Views\LeafInput\Index.cshtml" />
<Content Include="Views\LeafInput.cshtml" />
<Content Include="Views\LeafInput\Create.cshtml" />
<Content Include="Views\Shared\_StatusMessage.cshtml" />
<Content Include="Views\Shared\_ValidationField.cshtml" />
<Content Include="Views\Shared\_ValidationSummary.cshtml" />
@@ -358,6 +365,7 @@
<Content Include="Views\Shared\EditorTemplates\String.cshtml" />
<Content Include="Views\Shared\EditorTemplates\Text.cshtml" />
<Content Include="Views\Shared\EditorTemplates\TimeSpan.cshtml" />
<Content Include="Views\MacroPartials\LeafInputCreate.cshtml" />
<None Include="Web.Debug.config">
<DependentUpon>Web.config</DependentUpon>
</None>
@@ -398,6 +406,8 @@
<Content Include="Web.config" />
</ItemGroup>
<ItemGroup>
<Compile Include="App_Start\RegisterDataService.cs" />
<Compile Include="Controllers\ControllerBase.cs" />
<Compile Include="Controllers\LeafInputController.cs" />
<Compile Include="Models\LeafInputConfirm.cs" />
<Compile Include="Models\LeafInputCreate.cs" />
@@ -415,6 +425,7 @@
<Name>Core</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup />
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
+1
View File
@@ -3,6 +3,7 @@
<package id="AutoMapper" version="3.3.1" targetFramework="net452" />
<package id="ClientDependency" version="1.9.1" targetFramework="net452" />
<package id="ClientDependency-Mvc5" version="1.8.0.0" targetFramework="net452" />
<package id="EntityFramework" version="6.1.3" targetFramework="net452" />
<package id="Examine" version="0.1.70.0" targetFramework="net452" />
<package id="HtmlAgilityPack" version="1.4.9" targetFramework="net452" />
<package id="ImageProcessor" version="2.4.5.0" targetFramework="net452" />