refactoring
This commit is contained in:
parent
347ffc8a5a
commit
b5d19c5da6
38 changed files with 149 additions and 117 deletions
|
|
@ -6,11 +6,68 @@ using System.Web.Mvc;
|
|||
using System.Web.Mvc.Ajax;
|
||||
using System.Web.Security;
|
||||
using Yavsc.Model.RolesAndMembers;
|
||||
using Yavsc.Model.Admin;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
public class AdminController : Controller
|
||||
{
|
||||
[Authorize(Roles="Admin")]
|
||||
public ActionResult Index(DataAccess model)
|
||||
{
|
||||
return View (model);
|
||||
}
|
||||
|
||||
[Authorize(Roles="Admin")]
|
||||
public ActionResult Backups(DataAccess model)
|
||||
{
|
||||
return View (model);
|
||||
}
|
||||
|
||||
[Authorize(Roles="Admin")]
|
||||
public ActionResult CreateBackup(DataAccess datac)
|
||||
{
|
||||
if (datac != null) {
|
||||
if (ModelState.IsValid) {
|
||||
if (string.IsNullOrEmpty (datac.Password))
|
||||
ModelState.AddModelError ("Password", "Invalid passord");
|
||||
DataManager ex = new DataManager (datac);
|
||||
Export e = ex.CreateBackup ();
|
||||
if (e.ExitCode > 0)
|
||||
ModelState.AddModelError ("Password", "Operation Failed");
|
||||
return View ("BackupCreated", e);
|
||||
}
|
||||
} else {
|
||||
datac = new DataAccess ();
|
||||
}
|
||||
return View (datac);
|
||||
}
|
||||
|
||||
[Authorize(Roles="Admin")]
|
||||
public ActionResult CreateUserBackup(DataAccess datac,string username)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
[Authorize(Roles="Admin")]
|
||||
public ActionResult Upgrade(DataAccess datac) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
[Authorize(Roles="Admin")]
|
||||
public ActionResult Restore(DataAccess datac,string backupName,bool dataOnly=true)
|
||||
{
|
||||
ViewData ["BackupName"] = backupName;
|
||||
if (ModelState.IsValid) {
|
||||
DataManager mgr = new DataManager (datac);
|
||||
ViewData ["BackupName"] = backupName;
|
||||
ViewData ["DataOnly"] = dataOnly;
|
||||
TaskOutput t = mgr.Restore (backupName,dataOnly);
|
||||
return View ("Restored", t);
|
||||
}
|
||||
return View (datac);
|
||||
}
|
||||
|
||||
[Authorize(Roles="Admin")]
|
||||
public ActionResult RemoveFromRole(string username, string rolename, string returnUrl)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -4,69 +4,18 @@ using System.Linq;
|
|||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using Yavsc.Admin;
|
||||
using Yavsc.Model.Admin;
|
||||
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
public class BackOfficeController : Controller
|
||||
{
|
||||
[Authorize(Roles="Admin")]
|
||||
public ActionResult Index(DataAccess model)
|
||||
public ActionResult Estimate()
|
||||
{
|
||||
return View (model);
|
||||
}
|
||||
[Authorize(Roles="Admin")]
|
||||
public ActionResult Backups(DataAccess model)
|
||||
{
|
||||
return View (model);
|
||||
}
|
||||
|
||||
[Authorize(Roles="Admin")]
|
||||
public ActionResult CreateBackup(DataAccess datac)
|
||||
public ActionResult Index ()
|
||||
{
|
||||
if (datac != null) {
|
||||
if (ModelState.IsValid) {
|
||||
if (string.IsNullOrEmpty (datac.Password))
|
||||
ModelState.AddModelError ("Password", "Invalid passord");
|
||||
DataManager ex = new DataManager (datac);
|
||||
Export e = ex.CreateBackup ();
|
||||
if (e.ExitCode > 0)
|
||||
ModelState.AddModelError ("Password", "Operation Failed");
|
||||
return View ("BackupCreated", e);
|
||||
}
|
||||
} else {
|
||||
datac = new DataAccess ();
|
||||
}
|
||||
return View (datac);
|
||||
}
|
||||
|
||||
[Authorize(Roles="Admin")]
|
||||
public ActionResult CreateUserBackup(DataAccess datac,string username)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
[Authorize(Roles="Admin")]
|
||||
public ActionResult Upgrade(DataAccess datac) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
[Authorize(Roles="Admin")]
|
||||
public ActionResult Restore(DataAccess datac,string backupName,bool dataOnly=true)
|
||||
{
|
||||
ViewData ["BackupName"] = backupName;
|
||||
if (ModelState.IsValid) {
|
||||
DataManager mgr = new DataManager (datac);
|
||||
ViewData ["BackupName"] = backupName;
|
||||
ViewData ["DataOnly"] = dataOnly;
|
||||
TaskOutput t = mgr.Restore (backupName,dataOnly);
|
||||
return View ("Restored", t);
|
||||
}
|
||||
return View (datac);
|
||||
}
|
||||
|
||||
/*[Authorize(Roles="Admin")]
|
||||
public ActionResult Estimate*/
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ namespace Yavsc.ApiControllers
|
|||
[Authorize]
|
||||
public Estimate[] YourEstimates()
|
||||
{
|
||||
return WorkFlowProvider.WFManager.GetEstimates (
|
||||
return WorkFlowManager.GetEstimates (
|
||||
Membership.GetUser().UserName);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ namespace Yavsc.ApiControllers
|
|||
/// <param name="estid">Estid.</param>
|
||||
public Estimate GetEstimate (long estid)
|
||||
{
|
||||
Estimate est = WFManager.ContentProvider.GetEstimate (estid);
|
||||
Estimate est = WorkFlowManager.ContentProvider.GetEstimate (estid);
|
||||
return est;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
if (ModelState.IsValid) {
|
||||
if (e.Id > 0) {
|
||||
Estimate f = WFManager.GetEstimate (e.Id);
|
||||
Estimate f = WorkFlowManager.GetEstimate (e.Id);
|
||||
if (e.Owner != f.Owner)
|
||||
if (!Roles.IsUserInRole ("FrontOffice"))
|
||||
throw new UnauthorizedAccessException ("You're not allowed to modify this estimate");
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ namespace Yavsc.ApiControllers
|
|||
[Authorize]
|
||||
public long CreateEstimate (string title)
|
||||
{
|
||||
return WFManager.CreateEstimate (
|
||||
return WorkFlowManager.CreateEstimate (
|
||||
Membership.GetUser().UserName,title);
|
||||
}
|
||||
|
||||
|
|
@ -37,20 +37,20 @@ namespace Yavsc.ApiControllers
|
|||
[Authorize]
|
||||
public void DropWritting(long wrid)
|
||||
{
|
||||
WFManager.DropWritting (wrid);
|
||||
WorkFlowManager.DropWritting (wrid);
|
||||
}
|
||||
[HttpGet]
|
||||
[Authorize]
|
||||
public void UpdateWritting(Writting wr)
|
||||
{
|
||||
WFManager.UpdateWritting (wr);
|
||||
WorkFlowManager.UpdateWritting (wr);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Authorize]
|
||||
public void DropEstimate(long estid)
|
||||
{
|
||||
WFManager.DropEstimate (estid);
|
||||
WorkFlowManager.DropEstimate (estid);
|
||||
}
|
||||
[HttpGet]
|
||||
[Authorize]
|
||||
|
|
@ -68,7 +68,7 @@ namespace Yavsc.ApiControllers
|
|||
public long Write (long estid, string desc, decimal ucost, int count, long productid=0) {
|
||||
// TODO ensure estid owner matches the current one
|
||||
|
||||
return WFManager.Write(estid, desc, ucost, count, productid);
|
||||
return WorkFlowManager.Write(estid, desc, ucost, count, productid);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
<asp:Content ContentPlaceHolderID="MainContent" ID="MainContentContent" runat="server">
|
||||
|
||||
<%= Html.ValidationSummary() %>
|
||||
<% using(Html.BeginForm("DoAddRole", "Account")) %>
|
||||
<% using(Html.BeginForm("DoAddRole")) %>
|
||||
<% { %>
|
||||
Nom du rôle :
|
||||
<%= Html.TextBox( "RoleName" ) %>
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
</h2>
|
||||
<p><%= Html.ValidationSummary() %> </p>
|
||||
|
||||
<% using ( Html.BeginForm("Admin", "Account") ) { %>
|
||||
<% using ( Html.BeginForm("Admin", "Admin") ) { %>
|
||||
|
||||
<%= Html.LabelFor(model => model.UserName) %> :
|
||||
<%= Html.DropDownListFor(model => model.UserName, (List<SelectListItem>)ViewData["useritems"] ) %>
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<%@ Page Language="C#" MasterPageFile="~/Models/App.master" Inherits="System.Web.Mvc.ViewPage<DataAccess>" %>
|
||||
<asp:Content ID="MainContentContent" ContentPlaceHolderID="MainContent" runat="server">
|
||||
|
||||
<%=Html.ActionLink("Create a database backup", "CreateBackup", "BackOffice")%><br/>
|
||||
<%=Html.ActionLink("Restaurations", "Restore", "BackOffice")%><br/>
|
||||
<%=Html.ActionLink("Create a database backup", "CreateBackup")%><br/>
|
||||
<%=Html.ActionLink("Restaurations", "Restore")%><br/>
|
||||
</asp:Content>
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
<%@ Page Title="Backup creation" Language="C#" MasterPageFile="~/Models/App.master" Inherits="System.Web.Mvc.ViewPage<DataAccess>" %>
|
||||
<asp:Content ID="MainContentContent" ContentPlaceHolderID="MainContent" runat="server">
|
||||
<%= Html.ValidationSummary("CreateBackup") %>
|
||||
<% using (Html.BeginForm("CreateBackup","BackOffice")) { %>
|
||||
<% using (Html.BeginForm("CreateBackup")) { %>
|
||||
|
||||
<%= Html.LabelFor(model => model.Host) %>:
|
||||
<%= Html.TextBox( "Host" ) %>
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
<%@ Page Language="C#" MasterPageFile="~/Models/App.master" Inherits="System.Web.Mvc.ViewPage<DataAccess>" %>
|
||||
<asp:Content ID="MainContentContent" ContentPlaceHolderID="MainContent" runat="server">
|
||||
<%= Html.ActionLink("Backups","Backups","BackOffice") %>
|
||||
<%= Html.ActionLink("Backups","Backups") %>
|
||||
</asp:Content>
|
||||
|
|
@ -7,7 +7,7 @@
|
|||
<asp:Content ContentPlaceHolderID="MainContent" ID="MainContentContent" runat="server">
|
||||
<div>
|
||||
<%= Html.ValidationSummary() %>
|
||||
<% using ( Html.BeginForm("RemoveUser","Account") ) { %>
|
||||
<% using ( Html.BeginForm("RemoveUser") ) { %>
|
||||
Supprimer l'utilisateur
|
||||
<%= Html.Encode( ViewData["usertoremove"] ) %> ?
|
||||
<br/>
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
<%@ Page Language="C#" MasterPageFile="~/Models/App.master" Inherits="System.Web.Mvc.ViewPage<DataAccess>" %>
|
||||
<asp:Content ID="MainContentContent" ContentPlaceHolderID="MainContent" runat="server">
|
||||
<%= Html.ValidationSummary("Restore a database backup") %>
|
||||
<% using (Html.BeginForm("Restore","BackOffice")) { %>
|
||||
<% using (Html.BeginForm("Restore")) { %>
|
||||
|
||||
<% string [] bckdirs = Model.GetBackupDirs(); %>
|
||||
<select name="backupName">
|
||||
12
web/Views/BackOffice/Estimate.aspx
Normal file
12
web/Views/BackOffice/Estimate.aspx
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head runat="server">
|
||||
<title></title>
|
||||
</head>
|
||||
<body>
|
||||
<div>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
<%@ Page Language="C#" MasterPageFile="~/Models/App.master" Inherits="System.Web.Mvc.ViewPage<FormCollection collection>" %>
|
||||
<%@ Page Title="Commande" Language="C#" MasterPageFile="~/Models/App.master" Inherits="System.Web.Mvc.ViewPage<FormCollection collection>" %>
|
||||
|
||||
<asp:Content ID="MainContentContent" ContentPlaceHolderID="MainContent" runat="server">
|
||||
</asp:Content>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<%@ Page Title="Catalog" Language="C#" Inherits="System.Web.Mvc.ViewPage<Service>" MasterPageFile="~/Models/App.master" %>
|
||||
<asp:Content ContentPlaceHolderID="init" ID="init1" runat="server">
|
||||
<%= Title = ViewData ["BrandName"] + " " + Model.Name; %>
|
||||
<% Title = ViewData ["BrandName"] + " " + Model.Name; %>
|
||||
</asp:Content>
|
||||
<asp:Content ContentPlaceHolderID="header" ID="headerContent" runat="server">
|
||||
<h2> <%=ViewData ["ProdCatName"]%> - <%= Html.ActionLink( Model.Name, "Product", new { id = ViewData ["BrandName"], pc = ViewData ["ProdCatRef"] , pref = Model.Reference } ) %></h2>
|
||||
|
|
|
|||
|
|
@ -20,10 +20,10 @@ http://msdn2.microsoft.com/en-us/library/b5ysx397.aspx
|
|||
</sectionGroup>
|
||||
</sectionGroup>
|
||||
<sectionGroup name="system.web">
|
||||
<section name="blog" type="Npgsql.Web.Blog.Configuration.BlogProvidersConfigurationSection, NpgsqlBlogProvider" allowLocation="true" requirePermission="false" allowDefinition="Everywhere" />
|
||||
<section name="blog" type="Yavsc.Model.Blogs.Configuration.BlogProvidersConfigurationSection, YavscModel" allowLocation="true" requirePermission="false" allowDefinition="Everywhere" />
|
||||
<section name="thanks" type="Yavsc.ThanksConfigurationSection, Yavsc" allowLocation="true" requirePermission="false" allowDefinition="Everywhere" />
|
||||
<section name="catalog" type="SalesCatalog.Configuration.CatalogProvidersConfigurationSection, SalesCatalog" allowLocation="true" requirePermission="false" allowDefinition="Everywhere" />
|
||||
<section name="workflow" type="WorkFlowProvider.Configuration.WorkflowConfiguration, WorkFlowProvider" allowLocation="true" requirePermission="false" allowDefinition="Everywhere" />
|
||||
<section name="workflow" type="Yavsc.Model.WorkFlow.Configuration.WorkflowConfiguration, YavscModel" allowLocation="true" requirePermission="false" allowDefinition="Everywhere" />
|
||||
</sectionGroup>
|
||||
</configSections>
|
||||
<!-- <runtime>
|
||||
|
|
|
|||
|
|
@ -103,6 +103,7 @@
|
|||
<Folder Include="Views\FileSystem\" />
|
||||
<Folder Include="CatExts\" />
|
||||
<Folder Include="Views\WorkFlow\" />
|
||||
<Folder Include="Views\Admin\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Controllers\HomeController.cs" />
|
||||
|
|
@ -147,10 +148,7 @@
|
|||
<Content Include="Views\Account\ChangePassword.aspx" />
|
||||
<Content Include="Views\Account\ChangePasswordSuccess.aspx" />
|
||||
<Content Include="Views\Account\Index.aspx" />
|
||||
<Content Include="Views\Account\UserList.aspx" />
|
||||
<Content Include="Views\Account\Login.aspx" />
|
||||
<Content Include="Views\Account\RoleList.aspx" />
|
||||
<Content Include="Views\Account\Admin.aspx" />
|
||||
<Content Include="images\Banner.png" />
|
||||
<Content Include="images\noavatar.png" />
|
||||
<Content Include="images\apache_pbw.png" />
|
||||
|
|
@ -161,9 +159,6 @@
|
|||
<Content Include="Views\Blogs\UserPosts.aspx" />
|
||||
<Content Include="Views\Blogs\UserPost.aspx" />
|
||||
<Content Include="Views\Blogs\Edit.aspx" />
|
||||
<Content Include="Views\Account\RemoveUserQuery.aspx" />
|
||||
<Content Include="Views\Account\RemoveRoleQuery.aspx" />
|
||||
<Content Include="Views\Account\AddRole.aspx" />
|
||||
<Content Include="Views\Blogs\Error.aspx" />
|
||||
<Content Include="Views\Account\RegistrationPending.aspx" />
|
||||
<Content Include="Views\Account\Validate.aspx" />
|
||||
|
|
@ -172,15 +167,9 @@
|
|||
<Content Include="Views\Blogs\TitleNotFound.aspx" />
|
||||
<Content Include="Views\FrontOffice\ProductCategory.aspx" />
|
||||
<Content Include="Views\FrontOffice\Product.aspx" />
|
||||
<Content Include="Views\BackOffice\BackupCreated.aspx" />
|
||||
<Content Include="Views\BackOffice\Index.aspx" />
|
||||
<Content Include="Views\BackOffice\Restore.aspx" />
|
||||
<Content Include="Views\Home\AOEMail.aspx" />
|
||||
<Content Include="errors\GeneralError.aspx" />
|
||||
<Content Include="errors\PageNotFound.aspx" />
|
||||
<Content Include="Views\BackOffice\Restored.aspx" />
|
||||
<Content Include="Views\BackOffice\Backups.aspx" />
|
||||
<Content Include="Views\BackOffice\CreateBackup.aspx" />
|
||||
<Content Include="Views\FrontOffice\Service.aspx" />
|
||||
<Content Include="Views\FrontOffice\ReferenceNotFound.aspx" />
|
||||
<Content Include="Views\FileSystem\Delete.aspx" />
|
||||
|
|
@ -193,6 +182,19 @@
|
|||
<Content Include="Views\WorkFlow\NewProject.aspx" />
|
||||
<Content Include="Views\WorkFlow\Index.aspx" />
|
||||
<Content Include="Views\Blogs\RemovePost.aspx" />
|
||||
<Content Include="Views\Admin\Admin.aspx" />
|
||||
<Content Include="Views\Admin\AddRole.aspx" />
|
||||
<Content Include="Views\Admin\UserList.aspx" />
|
||||
<Content Include="Views\Admin\RemoveRoleQuery.aspx" />
|
||||
<Content Include="Views\Admin\RemoveUserQuery.aspx" />
|
||||
<Content Include="Views\Admin\RoleList.aspx" />
|
||||
<Content Include="Views\BackOffice\Estimate.aspx" />
|
||||
<Content Include="Views\Admin\CreateBackup.aspx" />
|
||||
<Content Include="Views\Admin\BackupCreated.aspx" />
|
||||
<Content Include="Views\Admin\Backups.aspx" />
|
||||
<Content Include="Views\Admin\Restore.aspx" />
|
||||
<Content Include="Views\Admin\Restored.aspx" />
|
||||
<Content Include="Views\Admin\Index.aspx" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue