* Estimates as Tex or Pdf
* Estimate edition [mix Mvc&Ajax] * Billable&Bankable properties on profiles
This commit is contained in:
parent
2ac2338939
commit
b39a444cf0
31 changed files with 1101 additions and 218 deletions
|
|
@ -20,39 +20,54 @@ namespace Yavsc.Controllers
|
|||
/// </summary>
|
||||
public class FrontOfficeController : Controller
|
||||
{
|
||||
[Authorize]
|
||||
public ActionResult Estimates ()
|
||||
{
|
||||
string username = Membership.GetUser ().UserName;
|
||||
return View(WorkFlowManager.GetEstimates (username));
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
public ActionResult Estimate(Estimate model,string submit)
|
||||
{
|
||||
if (ModelState.IsValid) {
|
||||
ViewData ["WebApiUrl"] = "http://"+ Request.Url.Authority + "/api/WorkFlow";
|
||||
string username = HttpContext.User.Identity.Name;
|
||||
if (submit == null) {
|
||||
if (model.Id > 0) {
|
||||
Estimate f = WorkFlowManager.GetEstimate (model.Id);
|
||||
if (f == null) {
|
||||
ModelState.AddModelError ("Id", "Wrong Id");
|
||||
return View (model);
|
||||
}
|
||||
if (username != f.Owner)
|
||||
if (!Roles.IsUserInRole ("FrontOffice"))
|
||||
throw new UnauthorizedAccessException ("You're not allowed to view/modify this estimate");
|
||||
if (submit == "Update") {
|
||||
if (model != f) {
|
||||
WorkFlowManager.SetTitle (model.Id, model.Title);
|
||||
}
|
||||
} else if (submit == null) {
|
||||
model = f;
|
||||
}
|
||||
model = f;
|
||||
ModelState.Clear ();
|
||||
string username = HttpContext.User.Identity.Name;
|
||||
if (username != model.Responsible
|
||||
&& username != model.Client
|
||||
&& !Roles.IsUserInRole ("FrontOffice"))
|
||||
throw new UnauthorizedAccessException ("You're not allowed to view this estimate");
|
||||
|
||||
}
|
||||
} else if (ModelState.IsValid) {
|
||||
|
||||
ViewData ["WebApiUrl"] = "http://" + Request.Url.Authority + "/api/WorkFlow";
|
||||
string username = HttpContext.User.Identity.Name;
|
||||
if (username != model.Responsible
|
||||
&& username != model.Client
|
||||
&& !Roles.IsUserInRole ("FrontOffice"))
|
||||
throw new UnauthorizedAccessException ("You're not allowed to modify this estimate");
|
||||
|
||||
if (model.Id == 0)
|
||||
model = WorkFlowManager.CreateEstimate (
|
||||
username,
|
||||
model.Client, model.Title, model.Description);
|
||||
else
|
||||
WorkFlowManager.UpdateEstimate (model);
|
||||
|
||||
} else if (model.Id == 0 && submit=="Create") {
|
||||
// Create the estimate
|
||||
model.Id=WorkFlowManager.CreateEstimate (username,
|
||||
model.Title);
|
||||
model.Owner = username;
|
||||
}
|
||||
}
|
||||
return View(model);
|
||||
}
|
||||
|
||||
|
||||
|
||||
[AcceptVerbs("GET")]
|
||||
public ActionResult Catalog ()
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue