Skip to content

Commit

Permalink
Servers add. Relates to Baud-UCS#27 and Baud-UCS#28.
Browse files Browse the repository at this point in the history
  • Loading branch information
Berzeger committed Jul 14, 2015
1 parent 8391d39 commit c1b0d51
Show file tree
Hide file tree
Showing 11 changed files with 120 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,7 @@ public interface IServersRepository
Server GetServerDetail(int id);

void UpdateServer(int id, Server server);

Server AddServer(Server server);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,10 @@ public void UpdateServer(int id, Server server)
x => x.Name,
x => x.AgentUrl);
}

public Server AddServer(Server server)
{
return Context.Servers.Add(server);
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@
<data name="ActiveTo" xml:space="preserve">
<value>Aktivní do</value>
</data>
<data name="AddNewServer" xml:space="preserve">
<value>Přidat nový server</value>
</data>
<data name="AgentUrl" xml:space="preserve">
<value>URL agenta</value>
</data>
Expand Down Expand Up @@ -174,6 +177,9 @@
<data name="Neither_Filter" xml:space="preserve">
<value>Nezáleží</value>
</data>
<data name="NewServer" xml:space="preserve">
<value>Nový server</value>
</data>
<data name="No" xml:space="preserve">
<value>Ne</value>
</data>
Expand Down
6 changes: 6 additions & 0 deletions src/Server/DeploymentFramework/Resources/StringResources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@
<data name="ActiveTo" xml:space="preserve">
<value>Active to</value>
</data>
<data name="AddNewServer" xml:space="preserve">
<value>Add new server</value>
</data>
<data name="AgentUrl" xml:space="preserve">
<value>Agent URL</value>
</data>
Expand Down Expand Up @@ -174,6 +177,9 @@
<data name="Neither_Filter" xml:space="preserve">
<value>Neither</value>
</data>
<data name="NewServer" xml:space="preserve">
<value>New server</value>
</data>
<data name="No" xml:space="preserve">
<value>No</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Web;
using System.Web.Mvc;
using Baud.Deployment.BusinessLogic.Domain.Deployment.Contracts;
using Baud.Deployment.BusinessLogic.Domain.Deployment.Entities;
using Baud.Deployment.Web.Areas.Deployment.Models.Servers;
using Baud.Deployment.Web.Framework.Security;
using Baud.Deployment.Web.Framework.Web;
Expand Down Expand Up @@ -91,5 +92,32 @@ public virtual ActionResult Edit(int id, FormCollection form)
return RedirectToAction(Actions.Detail(id));
}
}

public virtual ActionResult Add()
{
return View();
}

[HttpPost]
[ValidateAntiForgeryToken]
public virtual ActionResult Add(FormCollection form)
{
using (var uow = _deploymentUow())
{
var server = new Server
{
Name = form.Get("Name"),
AgentUrl = form.Get("AgentUrl"),
Created = DateTime.Now,
CreatedBy = -2
};

uow.Servers.AddServer(server);
uow.Commit();

// TODO add confirmation toast message
return RedirectToAction(Actions.Detail(server.ID));
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
@model Baud.Deployment.BusinessLogic.Domain.Deployment.Entities.Server
@using Baud.Deployment.Resources

@{
ViewBag.Title = StringResources.NewServer;
}

<h2>@ViewBag.Title</h2>

@using (var f = Html.BeginCustomForm())
{
using (var s = f.BeginSection())
{
@s.FieldFor(m => m.Name)
@s.FieldFor(m => m.AgentUrl)
}

@Html.GuardedActionLink(StringResources.BackToList, MVC.Deployment.Servers.Index(), new SimpleHtmlAttributes("class", "btn btn-default"))

using (var n = f.BeginNavigation())
{
@n.Submit(StringResources.Save)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
}
</div>

@Html.GuardedActionLink(StringResources.AddNewServer, MVC.Deployment.Servers.Add())

@if (Model.Any())
{
<table class="table table-striped">
Expand Down Expand Up @@ -53,3 +55,4 @@ else
{
<p>@StringResources.NoData</p>
}

Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ public class ActionNamesClass
public readonly string Index = "Index";
public readonly string Detail = "Detail";
public readonly string Edit = "Edit";
public readonly string Add = "Add";
}

[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
Expand All @@ -100,6 +101,7 @@ public class ActionNameConstants
public const string Index = "Index";
public const string Detail = "Detail";
public const string Edit = "Edit";
public const string Add = "Add";
}


Expand All @@ -113,10 +115,12 @@ public class ViewsClass
public _ViewNamesClass ViewNames { get { return s_ViewNames; } }
public class _ViewNamesClass
{
public readonly string Add = "Add";
public readonly string Detail = "Detail";
public readonly string Edit = "Edit";
public readonly string Index = "Index";
}
public readonly string Add = "~/Areas/Deployment/Views/Servers/Add.cshtml";
public readonly string Detail = "~/Areas/Deployment/Views/Servers/Detail.cshtml";
public readonly string Edit = "~/Areas/Deployment/Views/Servers/Edit.cshtml";
public readonly string Index = "~/Areas/Deployment/Views/Servers/Index.cshtml";
Expand Down Expand Up @@ -178,6 +182,29 @@ public override System.Web.Mvc.ActionResult Edit(int id, System.Web.Mvc.FormColl
return callInfo;
}

[NonAction]
partial void AddOverride(T4MVC_System_Web_Mvc_ActionResult callInfo);

[NonAction]
public override System.Web.Mvc.ActionResult Add()
{
var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.Add);
AddOverride(callInfo);
return callInfo;
}

[NonAction]
partial void AddOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, System.Web.Mvc.FormCollection form);

[NonAction]
public override System.Web.Mvc.ActionResult Add(System.Web.Mvc.FormCollection form)
{
var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.Add);
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "form", form);
AddOverride(callInfo, form);
return callInfo;
}

}
}

Expand Down
9 changes: 0 additions & 9 deletions src/Server/DeploymentFramework/Web/T4MVC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,26 +94,17 @@ public static class Scripts {
public static string Url(string fileName) { return T4MVCHelpers.ProcessVirtualPath(URLPATH + "/" + fileName); }
public static readonly string _references_js = T4MVCHelpers.IsProduction() && T4Extensions.FileExists(URLPATH + "/_references.min.js") ? Url("_references.min.js") : Url("_references.js");
public static readonly string bootstrap_bundle_min_js = Url("bootstrap-bundle.min.js");
public static readonly string bootstrap_js = T4MVCHelpers.IsProduction() && T4Extensions.FileExists(URLPATH + "/bootstrap.min.js") ? Url("bootstrap.min.js") : Url("bootstrap.js");
public static readonly string bootstrap_min_js = Url("bootstrap.min.js");
public static readonly string jquery_1_10_2_intellisense_js = T4MVCHelpers.IsProduction() && T4Extensions.FileExists(URLPATH + "/jquery-1.10.2.intellisense.min.js") ? Url("jquery-1.10.2.intellisense.min.js") : Url("jquery-1.10.2.intellisense.js");
public static readonly string jquery_1_10_2_js = T4MVCHelpers.IsProduction() && T4Extensions.FileExists(URLPATH + "/jquery-1.10.2.min.js") ? Url("jquery-1.10.2.min.js") : Url("jquery-1.10.2.js");
public static readonly string jquery_1_10_2_min_js = Url("jquery-1.10.2.min.js");
public static readonly string jquery_1_10_2_min_map = Url("jquery-1.10.2.min.map");
public static readonly string jquery_bundle_min_js = Url("jquery-bundle.min.js");
public static readonly string jquery_validate_unobtrusive_bootstrap_js = T4MVCHelpers.IsProduction() && T4Extensions.FileExists(URLPATH + "/jquery.validate.unobtrusive.bootstrap.min.js") ? Url("jquery.validate.unobtrusive.bootstrap.min.js") : Url("jquery.validate.unobtrusive.bootstrap.js");
public static readonly string jquery_validate_unobtrusive_chameleon_js = T4MVCHelpers.IsProduction() && T4Extensions.FileExists(URLPATH + "/jquery.validate.unobtrusive.chameleon.min.js") ? Url("jquery.validate.unobtrusive.chameleon.min.js") : Url("jquery.validate.unobtrusive.chameleon.js");
public static readonly string modernizer_min_js = T4MVCHelpers.IsProduction() && T4Extensions.FileExists(URLPATH + "/modernizer-min.min.js") ? Url("modernizer-min.min.js") : Url("modernizer-min.js");
public static readonly string modernizr_2_6_2_js = T4MVCHelpers.IsProduction() && T4Extensions.FileExists(URLPATH + "/modernizr-2.6.2.min.js") ? Url("modernizr-2.6.2.min.js") : Url("modernizr-2.6.2.js");
}

[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public static class Content {
private const string URLPATH = "~/Content";
public static string Url() { return T4MVCHelpers.ProcessVirtualPath(URLPATH); }
public static string Url(string fileName) { return T4MVCHelpers.ProcessVirtualPath(URLPATH + "/" + fileName); }
public static readonly string bootstrap_css = T4MVCHelpers.IsProduction() && T4Extensions.FileExists(URLPATH + "/bootstrap.min.css") ? Url("bootstrap.min.css") : Url("bootstrap.css");
public static readonly string bootstrap_min_css = Url("bootstrap.min.css");
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public static class dist {
private const string URLPATH = "~/Content/dist";
Expand Down
1 change: 1 addition & 0 deletions src/Server/DeploymentFramework/Web/Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@
<Content Include="Areas\Security\Views\Roles\Index.cshtml" />
<Content Include="Areas\Security\Views\Positions\Index.cshtml" />
<Content Include="Areas\Security\Views\Positions\UpdateName.cshtml" />
<Content Include="Areas\Deployment\Views\Servers\Add.cshtml" />
<None Include="T4MVC.tt.settings.xml" />
<Content Include="Web.config" />
<Content Include="Web.Debug.config">
Expand Down

0 comments on commit c1b0d51

Please sign in to comment.