diff --git a/src/Server/DeploymentFramework/BusinessLogic/Domain/Security/Contracts/IPositionsRepository.cs b/src/Server/DeploymentFramework/BusinessLogic/Domain/Security/Contracts/IPositionsRepository.cs
index 236810d..b84f986 100644
--- a/src/Server/DeploymentFramework/BusinessLogic/Domain/Security/Contracts/IPositionsRepository.cs
+++ b/src/Server/DeploymentFramework/BusinessLogic/Domain/Security/Contracts/IPositionsRepository.cs
@@ -17,6 +17,8 @@ public interface IPositionsRepository
void Disable(short id);
- void UpdateName(short id, string name);
+ void UpdateName(short id);
+
+ void AddPosition(Position position);
}
}
diff --git a/src/Server/DeploymentFramework/BusinessLogic/Domain/Security/Contracts/IRolesRepository.cs b/src/Server/DeploymentFramework/BusinessLogic/Domain/Security/Contracts/IRolesRepository.cs
index 851c8c4..9011d37 100644
--- a/src/Server/DeploymentFramework/BusinessLogic/Domain/Security/Contracts/IRolesRepository.cs
+++ b/src/Server/DeploymentFramework/BusinessLogic/Domain/Security/Contracts/IRolesRepository.cs
@@ -17,6 +17,8 @@ public interface IRolesRepository
void Disable(short id);
- void UpdateName(short id, string name);
+ void UpdateName(short id);
+
+ void AddRole(Role role);
}
}
diff --git a/src/Server/DeploymentFramework/Database/Security/PositionsRepository.cs b/src/Server/DeploymentFramework/Database/Security/PositionsRepository.cs
index dda2a69..0ba6f30 100644
--- a/src/Server/DeploymentFramework/Database/Security/PositionsRepository.cs
+++ b/src/Server/DeploymentFramework/Database/Security/PositionsRepository.cs
@@ -44,13 +44,17 @@ public void Disable(short id)
x => x.IsActive);
}
- public void UpdateName(short id, string name)
+ public void UpdateName(short id)
{
Position position = GetPositionDetail(id);
- position.Name = name;
Context.AttachAsModified(position,
x => x.Name);
}
+
+ public void AddPosition(Position position)
+ {
+ Context.Positions.Add(position);
+ }
}
}
diff --git a/src/Server/DeploymentFramework/Database/Security/RolesRepository.cs b/src/Server/DeploymentFramework/Database/Security/RolesRepository.cs
index fc9efff..896a748 100644
--- a/src/Server/DeploymentFramework/Database/Security/RolesRepository.cs
+++ b/src/Server/DeploymentFramework/Database/Security/RolesRepository.cs
@@ -44,13 +44,17 @@ public void Disable(short id)
x => x.IsActive);
}
- public void UpdateName(short id, string name)
+ public void UpdateName(short id)
{
Role role = GetRoleDetail(id);
- role.Name = name;
Context.AttachAsModified(role,
x => x.Name);
}
+
+ public void AddRole(Role role)
+ {
+ Context.Roles.Add(role);
+ }
}
}
diff --git a/src/Server/DeploymentFramework/Resources/StringResources.Designer.cs b/src/Server/DeploymentFramework/Resources/StringResources.Designer.cs
index 48ddf8b..a143038 100644
--- a/src/Server/DeploymentFramework/Resources/StringResources.Designer.cs
+++ b/src/Server/DeploymentFramework/Resources/StringResources.Designer.cs
@@ -78,6 +78,24 @@ public static string ActiveTo {
}
}
+ ///
+ /// Looks up a localized string similar to Add new position.
+ ///
+ public static string AddNewPosition {
+ get {
+ return ResourceManager.GetString("AddNewPosition", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Add new role.
+ ///
+ public static string AddNewRole {
+ get {
+ return ResourceManager.GetString("AddNewRole", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Add new user.
///
diff --git a/src/Server/DeploymentFramework/Resources/StringResources.cs-CZ.resx b/src/Server/DeploymentFramework/Resources/StringResources.cs-CZ.resx
index fa49560..9f1956e 100644
--- a/src/Server/DeploymentFramework/Resources/StringResources.cs-CZ.resx
+++ b/src/Server/DeploymentFramework/Resources/StringResources.cs-CZ.resx
@@ -123,6 +123,12 @@
Aktivní do
+
+ Přidat novou pozici
+
+
+ Přidat novou roli
+
Přidat nového uživatele
diff --git a/src/Server/DeploymentFramework/Resources/StringResources.resx b/src/Server/DeploymentFramework/Resources/StringResources.resx
index 70d4dde..379dfa3 100644
--- a/src/Server/DeploymentFramework/Resources/StringResources.resx
+++ b/src/Server/DeploymentFramework/Resources/StringResources.resx
@@ -123,6 +123,12 @@
Active to
+
+ Add new position
+
+
+ Add new role
+
Add new user
diff --git a/src/Server/DeploymentFramework/Web/Areas/Security/Controllers/PositionsController.cs b/src/Server/DeploymentFramework/Web/Areas/Security/Controllers/PositionsController.cs
index c99e6a3..d8d726a 100644
--- a/src/Server/DeploymentFramework/Web/Areas/Security/Controllers/PositionsController.cs
+++ b/src/Server/DeploymentFramework/Web/Areas/Security/Controllers/PositionsController.cs
@@ -4,6 +4,7 @@
using System.Web;
using System.Web.Mvc;
using Baud.Deployment.BusinessLogic.Domain.Security.Contracts;
+using Baud.Deployment.BusinessLogic.Domain.Security.Entities;
using Baud.Deployment.Web.Areas.Security.Models.Positions;
using Baud.Deployment.Web.Framework.Web;
@@ -60,11 +61,6 @@ public virtual ActionResult Disable(short id)
return HttpNotFound();
}
- if (!TryUpdateModel(position))
- {
- return View(position);
- }
-
uow.Positions.Disable(id);
uow.Commit();
@@ -84,11 +80,6 @@ public virtual ActionResult Enable(short id)
return HttpNotFound();
}
- if (!TryUpdateModel(position))
- {
- return View(position);
- }
-
uow.Positions.Enable(id);
uow.Commit();
@@ -115,7 +106,7 @@ public virtual ActionResult UpdateName(short id, string name)
return View(position);
}
- uow.Positions.UpdateName(id, name);
+ uow.Positions.UpdateName(id);
uow.Commit();
// TODO add confirmation toast message
@@ -137,5 +128,35 @@ public virtual ActionResult UpdateName(short id)
return View(position);
}
}
+
+ public virtual ActionResult Add()
+ {
+ return View();
+ }
+
+ [HttpPost]
+ [ValidateAntiForgeryToken]
+ public virtual ActionResult Add(FormCollection form)
+ {
+ using (var uow = _securityUow())
+ {
+ var position = new Position();
+
+ // TODO Following two lines need fixing (we shouldn't have to type these properties in manually).
+ position.Created = DateTime.Now;
+ position.CreatedBy = -2;
+
+ if (!TryUpdateModel(position))
+ {
+ return View(position);
+ }
+
+ uow.Positions.AddPosition(position);
+ uow.Commit();
+
+ // TODO add confirmation toast message
+ return RedirectToAction(Actions.Index());
+ }
+ }
}
}
\ No newline at end of file
diff --git a/src/Server/DeploymentFramework/Web/Areas/Security/Controllers/RolesController.cs b/src/Server/DeploymentFramework/Web/Areas/Security/Controllers/RolesController.cs
index d35995e..aecfb57 100644
--- a/src/Server/DeploymentFramework/Web/Areas/Security/Controllers/RolesController.cs
+++ b/src/Server/DeploymentFramework/Web/Areas/Security/Controllers/RolesController.cs
@@ -4,6 +4,7 @@
using System.Web;
using System.Web.Mvc;
using Baud.Deployment.BusinessLogic.Domain.Security.Contracts;
+using Baud.Deployment.BusinessLogic.Domain.Security.Entities;
using Baud.Deployment.Web.Areas.Security.Models.Roles;
using Baud.Deployment.Web.Framework.Security;
using Baud.Deployment.Web.Framework.Web;
@@ -61,11 +62,6 @@ public virtual ActionResult Disable(short id)
return HttpNotFound();
}
- if (!TryUpdateModel(role))
- {
- return View(role);
- }
-
uow.Roles.Disable(id);
uow.Commit();
@@ -85,11 +81,6 @@ public virtual ActionResult Enable(short id)
return HttpNotFound();
}
- if (!TryUpdateModel(role))
- {
- return View(role);
- }
-
uow.Roles.Enable(id);
uow.Commit();
@@ -116,7 +107,7 @@ public virtual ActionResult UpdateName(short id, string name)
return View(role);
}
- uow.Roles.UpdateName(id, name);
+ uow.Roles.UpdateName(id);
uow.Commit();
// TODO add confirmation toast message
@@ -138,5 +129,35 @@ public virtual ActionResult UpdateName(short id)
return View(role);
}
}
+
+ public virtual ActionResult Add()
+ {
+ return View();
+ }
+
+ [HttpPost]
+ [ValidateAntiForgeryToken]
+ public virtual ActionResult Add(FormCollection form)
+ {
+ using (var uow = _securityUow())
+ {
+ var role = new Role();
+
+ // TODO Following two lines need fixing (we shouldn't have to type these properties in manually).
+ role.Created = DateTime.Now;
+ role.CreatedBy = -2;
+
+ if (!TryUpdateModel(role))
+ {
+ return View(role);
+ }
+
+ uow.Roles.AddRole(role);
+ uow.Commit();
+
+ // TODO add confirmation toast message
+ return RedirectToAction(Actions.Index());
+ }
+ }
}
}
\ No newline at end of file
diff --git a/src/Server/DeploymentFramework/Web/Areas/Security/Views/Positions/Add.cshtml b/src/Server/DeploymentFramework/Web/Areas/Security/Views/Positions/Add.cshtml
new file mode 100644
index 0000000..7b3ef18
--- /dev/null
+++ b/src/Server/DeploymentFramework/Web/Areas/Security/Views/Positions/Add.cshtml
@@ -0,0 +1,22 @@
+@model Baud.Deployment.BusinessLogic.Domain.Security.Entities.Position
+@using Baud.Deployment.Resources
+
+@{
+ ViewBag.Title = StringResources.AddNewPosition;
+}
+
+
@ViewBag.Title
+
+@using (var f = Html.BeginCustomForm())
+{
+ using (var s = f.BeginSection())
+ {
+ @s.FieldFor(m => m.Name)
+ @s.FieldFor(m => m.IsActive).AsDropDown().WithTrueAs(StringResources.Yes).WithFalseAs(StringResources.No)
+ }
+
+ using (var n = f.BeginNavigation())
+ {
+ @n.Submit(StringResources.Save)
+ }
+}
diff --git a/src/Server/DeploymentFramework/Web/Areas/Security/Views/Positions/Index.cshtml b/src/Server/DeploymentFramework/Web/Areas/Security/Views/Positions/Index.cshtml
index c547904..77985e4 100644
--- a/src/Server/DeploymentFramework/Web/Areas/Security/Views/Positions/Index.cshtml
+++ b/src/Server/DeploymentFramework/Web/Areas/Security/Views/Positions/Index.cshtml
@@ -24,6 +24,8 @@
}
+@Html.GuardedActionLink(StringResources.AddNewPosition, MVC.Security.Positions.Add())
+
@if (Model.Any())
{
diff --git a/src/Server/DeploymentFramework/Web/Areas/Security/Views/Roles/Add.cshtml b/src/Server/DeploymentFramework/Web/Areas/Security/Views/Roles/Add.cshtml
new file mode 100644
index 0000000..f08bac7
--- /dev/null
+++ b/src/Server/DeploymentFramework/Web/Areas/Security/Views/Roles/Add.cshtml
@@ -0,0 +1,22 @@
+@model Baud.Deployment.BusinessLogic.Domain.Security.Entities.Role
+@using Baud.Deployment.Resources
+
+@{
+ ViewBag.Title = StringResources.AddNewRole;
+}
+
+@ViewBag.Title
+
+@using (var f = Html.BeginCustomForm())
+{
+ using (var s = f.BeginSection())
+ {
+ @s.FieldFor(m => m.Name)
+ @s.FieldFor(m => m.IsActive).AsDropDown().WithTrueAs(StringResources.Yes).WithFalseAs(StringResources.No)
+ }
+
+ using (var n = f.BeginNavigation())
+ {
+ @n.Submit(StringResources.Save)
+ }
+}
diff --git a/src/Server/DeploymentFramework/Web/Areas/Security/Views/Roles/Index.cshtml b/src/Server/DeploymentFramework/Web/Areas/Security/Views/Roles/Index.cshtml
index 4b844e8..cc725c1 100644
--- a/src/Server/DeploymentFramework/Web/Areas/Security/Views/Roles/Index.cshtml
+++ b/src/Server/DeploymentFramework/Web/Areas/Security/Views/Roles/Index.cshtml
@@ -24,6 +24,8 @@
}
+@Html.GuardedActionLink(StringResources.AddNewRole, MVC.Security.Roles.Add())
+
@if (Model.Any())
{
diff --git a/src/Server/DeploymentFramework/Web/Security.PositionsController.generated.cs b/src/Server/DeploymentFramework/Web/Security.PositionsController.generated.cs
index 355375c..93e1222 100644
--- a/src/Server/DeploymentFramework/Web/Security.PositionsController.generated.cs
+++ b/src/Server/DeploymentFramework/Web/Security.PositionsController.generated.cs
@@ -106,6 +106,7 @@ public class ActionNamesClass
public readonly string Disable = "Disable";
public readonly string Enable = "Enable";
public readonly string UpdateName = "UpdateName";
+ public readonly string Add = "Add";
}
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
@@ -116,6 +117,7 @@ public class ActionNameConstants
public const string Disable = "Disable";
public const string Enable = "Enable";
public const string UpdateName = "UpdateName";
+ public const string Add = "Add";
}
@@ -129,9 +131,11 @@ public class ViewsClass
public _ViewNamesClass ViewNames { get { return s_ViewNames; } }
public class _ViewNamesClass
{
+ public readonly string Add = "Add";
public readonly string Index = "Index";
public readonly string UpdateName = "UpdateName";
}
+ public readonly string Add = "~/Areas/Security/Views/Positions/Add.cshtml";
public readonly string Index = "~/Areas/Security/Views/Positions/Index.cshtml";
public readonly string UpdateName = "~/Areas/Security/Views/Positions/UpdateName.cshtml";
}
@@ -216,6 +220,29 @@ public override System.Web.Mvc.ActionResult UpdateName(short id)
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;
+ }
+
}
}
diff --git a/src/Server/DeploymentFramework/Web/Security.RolesController.generated.cs b/src/Server/DeploymentFramework/Web/Security.RolesController.generated.cs
index 1aa19ee..474b9a6 100644
--- a/src/Server/DeploymentFramework/Web/Security.RolesController.generated.cs
+++ b/src/Server/DeploymentFramework/Web/Security.RolesController.generated.cs
@@ -106,6 +106,7 @@ public class ActionNamesClass
public readonly string Disable = "Disable";
public readonly string Enable = "Enable";
public readonly string UpdateName = "UpdateName";
+ public readonly string Add = "Add";
}
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
@@ -116,6 +117,7 @@ public class ActionNameConstants
public const string Disable = "Disable";
public const string Enable = "Enable";
public const string UpdateName = "UpdateName";
+ public const string Add = "Add";
}
@@ -129,9 +131,11 @@ public class ViewsClass
public _ViewNamesClass ViewNames { get { return s_ViewNames; } }
public class _ViewNamesClass
{
+ public readonly string Add = "Add";
public readonly string Index = "Index";
public readonly string UpdateName = "UpdateName";
}
+ public readonly string Add = "~/Areas/Security/Views/Roles/Add.cshtml";
public readonly string Index = "~/Areas/Security/Views/Roles/Index.cshtml";
public readonly string UpdateName = "~/Areas/Security/Views/Roles/UpdateName.cshtml";
}
@@ -216,6 +220,29 @@ public override System.Web.Mvc.ActionResult UpdateName(short id)
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;
+ }
+
}
}
diff --git a/src/Server/DeploymentFramework/Web/Web.csproj b/src/Server/DeploymentFramework/Web/Web.csproj
index 7d6cc50..e3df9fd 100644
--- a/src/Server/DeploymentFramework/Web/Web.csproj
+++ b/src/Server/DeploymentFramework/Web/Web.csproj
@@ -430,6 +430,8 @@
+
+