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);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue