Files
ayanova7/source/ri/ri/Controllers/ShowAllController.cs
2018-06-29 19:47:36 +00:00

395 lines
16 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ri.util;
using ri.Models;
using GZTW.AyaNova.BLL;
namespace ri.Controllers
{
public class ShowAllController : Controller
{
//CLIENT LISTS
#region Show all client service work orders
public ActionResult ClientServiceWO(Guid Id)
{
ShowAllClientWOCriteriaModel model = null;
if (Session["ShowAllClientWOCriteria"] != null)
model = (ShowAllClientWOCriteriaModel)Session["ShowAllClientWOCriteria"];
if (model == null || model.objectId != Id)
{
Session["ShowAllClientWOCriteria"] = null;
//SET DEFAULTS
model = new ShowAllClientWOCriteriaModel();
model.objectId = Id;
model.objectName = NameFetcher.GetItem(new TypeAndID(RootObjectTypes.Client, Id)).RecordName;
}
//set rights and urls
util.ay.setViewBagRights(ViewBag, RootObjectTypes.WorkorderService);
ViewBag.newItemUrl = ay.genBaseSiteUrl(Url) + "Workorder/Create?ClientId=" + Id.ToString() + "&WType="+((int)WorkorderTypes.Service).ToString();
return View(model);
}
[HttpPost]
public ActionResult ClientServiceWO(FormCollection f)
{
//now get the individual form choices
ShowAllClientWOCriteriaModel model = new ShowAllClientWOCriteriaModel();
model.objectId = ay.parseGuid("hdObjectId", f);
model.filter = ay.parseBool("ckFilter", f);
model.closed = f["plClosed"];
model.serviceCompleted = f["plServiceCompleted"];
model.workorderStatus = ay.parseGuid("plWorkorderStatus", f);
model.serviceDateRange = f["plServiceDateRange"];
model.maxRecords = f["plMaxRecords"];
Session["ShowAllClientWOCriteria"] = model;
return RedirectToAction("ClientServiceWO", new { Id = model.objectId });
}
#endregion Show all client workorders
#region Show all client quotes
public ActionResult ClientQuote(Guid Id)
{
ShowAllClientQuoteModel model = null;
if (Session["ShowAllClientQuoteModel"] != null)
model = (ShowAllClientQuoteModel)Session["ShowAllClientQuoteModel"];
if (model == null || model.objectId != Id)
{
Session["ShowAllClientQuoteModel"] = null;
//SET DEFAULTS
model = new ShowAllClientQuoteModel();
model.objectId = Id;
model.objectName = NameFetcher.GetItem(new TypeAndID(RootObjectTypes.Client, Id)).RecordName;
}
//set rights and urls
util.ay.setViewBagRights(ViewBag, RootObjectTypes.WorkorderQuote);
ViewBag.newItemUrl = ay.genBaseSiteUrl(Url) + "Workorder/Create?ClientId=" + Id.ToString() + "&WType=" + ((int)WorkorderTypes.Quote).ToString();
return View(model);
}
[HttpPost]
public ActionResult ClientQuote(FormCollection f)
{
//now get the individual form choices
ShowAllClientQuoteModel model = new ShowAllClientQuoteModel();
model.objectId = ay.parseGuid("hdObjectId", f);
model.filter = ay.parseBool("ckFilter", f);
model.quoteStatus = f["plQuoteStatus"];
model.requestedDateRange = f["plRequestedDateRange"];
model.submittedDateRange = f["plSubmittedDateRange"];
model.validUntilDateRange = f["plValidUntilDateRange"];
model.approvedDateRange = f["plApprovedDateRange"];
model.maxRecords = f["plMaxRecords"];
Session["ShowAllClientQuoteModel"] = model;
return RedirectToAction("ClientQuote", new { Id = model.objectId });
}
#endregion Show all client quotes
#region Show all client PM's
public ActionResult ClientPM(Guid Id)
{
ShowAllClientPMCriteriaModel model = null;
if (Session["ShowAllClientPMCriteriaModel"] != null)
model = (ShowAllClientPMCriteriaModel)Session["ShowAllClientPMCriteriaModel"];
if (model == null || model.objectId != Id)
{
Session["ShowAllClientPMCriteriaModel"] = null;
//SET DEFAULTS
model = new ShowAllClientPMCriteriaModel();
model.objectId = Id;
model.objectName = NameFetcher.GetItem(new TypeAndID(RootObjectTypes.Client, Id)).RecordName;
}
//set rights and urls
util.ay.setViewBagRights(ViewBag, RootObjectTypes.WorkorderPreventiveMaintenance);
ViewBag.newItemUrl = ay.genBaseSiteUrl(Url) + "Workorder/Create?ClientId=" + Id.ToString() + "&WType=" + ((int)WorkorderTypes.PreventiveMaintenance).ToString();
return View(model);
}
[HttpPost]
public ActionResult ClientPM(FormCollection f)
{
//now get the individual form choices
ShowAllClientPMCriteriaModel model = new ShowAllClientPMCriteriaModel();
model.objectId = ay.parseGuid("hdObjectId", f);
model.filter = ay.parseBool("ckFilter", f);
model.nextServiceDateRange = f["plNextServiceDate"];
model.maxRecords = f["plMaxRecords"];
Session["ShowAllClientPMCriteriaModel"] = model;
return RedirectToAction("ClientPM", new { Id = model.objectId });
}
#endregion Show all client pm
#region Show all client CSR
public ActionResult ClientCSR(Guid Id)
{
ShowAllClientCSRCriteriaModel model = null;
if (Session["ShowAllClientCSRCriteriaModel"] != null)
model = (ShowAllClientCSRCriteriaModel)Session["ShowAllClientCSRCriteriaModel"];
if (model == null || model.objectId != Id)
{
Session["ShowAllClientCSRCriteriaModel"] = null;
//SET DEFAULTS
model = new ShowAllClientCSRCriteriaModel();
model.objectId = Id;
model.objectName = NameFetcher.GetItem(new TypeAndID(RootObjectTypes.Client, Id)).RecordName;
}
//set rights and urls
util.ay.setViewBagRights(ViewBag, RootObjectTypes.ClientServiceRequest);
return View(model);
}
[HttpPost]
public ActionResult ClientCSR(FormCollection f)
{
//now get the individual form choices
ShowAllClientCSRCriteriaModel model = new ShowAllClientCSRCriteriaModel();
model.objectId = ay.parseGuid("hdObjectId", f);
model.filter = ay.parseBool("ckFilter", f);
model.maxRecords = f["plMaxRecords"];
model.createdDateRange = f["plCreatedDateRange"];
model.csrPriority = f["plPriority"];
model.csrStatus = f["plStatus"];
model.csrUnitId = ay.parseGuid("plUnitId", f);
Session["ShowAllClientCSRCriteriaModel"] = model;
return RedirectToAction("ClientCSR", new { Id = model.objectId });
}
#endregion Show all client CSR
#region Show all client Units
public ActionResult ClientUnit(Guid Id)
{
ShowAllClientUnitModel model = null;
if (Session["ShowAllClientUnitModel"] != null)
model = (ShowAllClientUnitModel)Session["ShowAllClientUnitModel"];
if (model == null || model.objectId != Id)
{
Session["ShowAllClientUnitModel"] = null;
//SET DEFAULTS
model = new ShowAllClientUnitModel();
model.objectId = Id;
model.objectName = NameFetcher.GetItem(new TypeAndID(RootObjectTypes.Client, Id)).RecordName;
}
//set rights and urls
util.ay.setViewBagRights(ViewBag, RootObjectTypes.Unit);
ViewBag.newItemUrl = ay.genBaseSiteUrl(Url) + "Unit/Create?ClientId=" + Id.ToString();
return View(model);
}
[HttpPost]
public ActionResult ClientUnit(FormCollection f)
{
//now get the individual form choices
ShowAllClientUnitModel model = new ShowAllClientUnitModel();
model.objectId = ay.parseGuid("hdObjectId", f);
model.filter = ay.parseBool("ckFilter", f);
model.maxRecords = f["plMaxRecords"];
model.metered = f["plMetered"];
model.banked = f["plBanked"];
model.unitModelId = ay.parseGuid("plUnitModelId", f);
Session["ShowAllClientUnitModel"] = model;
return RedirectToAction("ClientUnit", new { Id = model.objectId });
}
#endregion Show all client Units
//UNIT LISTS
#region Show all unit service work orders
public ActionResult UnitServiceWO(Guid Id)
{
ShowAllUnitWOCriteriaModel model = null;
if (Session["ShowAllUnitWOCriteria"] != null)
model = (ShowAllUnitWOCriteriaModel)Session["ShowAllUnitWOCriteria"];
if (model == null || model.objectId != Id)
{
Session["ShowAllUnitWOCriteria"] = null;
//SET DEFAULTS
model = new ShowAllUnitWOCriteriaModel();
model.objectId = Id;
model.objectName = NameFetcher.GetItem(new TypeAndID(RootObjectTypes.Unit, Id)).RecordName;
}
//set rights and urls
util.ay.setViewBagRights(ViewBag, RootObjectTypes.WorkorderService);
ViewBag.newItemUrl = ay.genBaseSiteUrl(Url) + "Workorder/CreateForUnit?UnitId=" + Id.ToString() + "&WType=" + ((int)WorkorderTypes.Service).ToString();
return View(model);
}
[HttpPost]
public ActionResult UnitServiceWO(FormCollection f)
{
//now get the individual form choices
ShowAllUnitWOCriteriaModel model = new ShowAllUnitWOCriteriaModel();
model.objectId = ay.parseGuid("hdObjectId", f);
model.filter = ay.parseBool("ckFilter", f);
model.closed = f["plClosed"];
model.serviceCompleted = f["plServiceCompleted"];
model.workorderStatus = ay.parseGuid("plWorkorderStatus", f);
model.serviceDateRange = f["plServiceDateRange"];
model.maxRecords = f["plMaxRecords"];
Session["ShowAllUnitWOCriteria"] = model;
return RedirectToAction("UnitServiceWO", new { Id = model.objectId });
}
#endregion Show all client workorders
#region Show all unit quotes
public ActionResult UnitQuote(Guid Id)
{
ShowAllUnitQuoteModel model = null;
if (Session["ShowAllUnitQuoteModel"] != null)
model = (ShowAllUnitQuoteModel)Session["ShowAllUnitQuoteModel"];
if (model == null || model.objectId != Id)
{
Session["ShowAllUnitQuoteModel"] = null;
//SET DEFAULTS
model = new ShowAllUnitQuoteModel();
model.objectId = Id;
model.objectName = NameFetcher.GetItem(new TypeAndID(RootObjectTypes.Unit, Id)).RecordName;
}
//set rights and urls
util.ay.setViewBagRights(ViewBag, RootObjectTypes.WorkorderQuote);
ViewBag.newItemUrl = ay.genBaseSiteUrl(Url) + "Workorder/CreateForUnit?UnitId=" + Id.ToString() + "&WType=" + ((int)WorkorderTypes.Quote).ToString();
return View(model);
}
[HttpPost]
public ActionResult UnitQuote(FormCollection f)
{
//now get the individual form choices
ShowAllUnitQuoteModel model = new ShowAllUnitQuoteModel();
model.objectId = ay.parseGuid("hdObjectId", f);
model.filter = ay.parseBool("ckFilter", f);
model.quoteStatus = f["plQuoteStatus"];
model.requestedDateRange = f["plRequestedDateRange"];
model.submittedDateRange = f["plSubmittedDateRange"];
model.validUntilDateRange = f["plValidUntilDateRange"];
model.approvedDateRange = f["plApprovedDateRange"];
model.maxRecords = f["plMaxRecords"];
Session["ShowAllUnitQuoteModel"] = model;
return RedirectToAction("UnitQuote", new { Id = model.objectId });
}
#endregion Show all unit quotes
#region Show all unit PM's
public ActionResult UnitPM(Guid Id)
{
ShowAllUnitPMCriteriaModel model = null;
if (Session["ShowAllUnitPMCriteriaModel"] != null)
model = (ShowAllUnitPMCriteriaModel)Session["ShowAllUnitPMCriteriaModel"];
if (model == null || model.objectId != Id)
{
Session["ShowAllUnitPMCriteriaModel"] = null;
//SET DEFAULTS
model = new ShowAllUnitPMCriteriaModel();
model.objectId = Id;
model.objectName = NameFetcher.GetItem(new TypeAndID(RootObjectTypes.Unit, Id)).RecordName;
}
//set rights and urls
util.ay.setViewBagRights(ViewBag, RootObjectTypes.WorkorderPreventiveMaintenance);
ViewBag.newItemUrl = ay.genBaseSiteUrl(Url) + "Workorder/CreateForUnit?UnitId=" + Id.ToString() + "&WType=" + ((int)WorkorderTypes.PreventiveMaintenance).ToString();
return View(model);
}
[HttpPost]
public ActionResult UnitPM(FormCollection f)
{
//now get the individual form choices
ShowAllUnitPMCriteriaModel model = new ShowAllUnitPMCriteriaModel();
model.objectId = ay.parseGuid("hdObjectId", f);
model.filter = ay.parseBool("ckFilter", f);
model.nextServiceDateRange = f["plNextServiceDate"];
model.maxRecords = f["plMaxRecords"];
Session["ShowAllUnitPMCriteriaModel"] = model;
return RedirectToAction("UnitPM", new { Id = model.objectId });
}
#endregion Show all unit pm
#region Show all unit CSR
public ActionResult UnitCSR(Guid UnitId)
{
Guid ClientId = UnitPickList.GetListOfOneSpecificUnit(UnitId)[0].ClientID;
ShowAllUnitCSRCriteriaModel model = null;
if (Session["ShowAllUnitCSRCriteriaModel"] != null)
model = (ShowAllUnitCSRCriteriaModel)Session["ShowAllUnitCSRCriteriaModel"];
if (model == null || model.objectId != ClientId || model.csrUnitId != UnitId)
{
Session["ShowAllUnitCSRCriteriaModel"] = null;
//SET DEFAULTS
model = new ShowAllUnitCSRCriteriaModel();
model.objectId = ClientId;
model.csrUnitId = UnitId;
model.objectName = NameFetcher.GetItem(new TypeAndID(RootObjectTypes.Client, ClientId)).RecordName;
}
//set rights and urls
util.ay.setViewBagRights(ViewBag, RootObjectTypes.ClientServiceRequest);
return View(model);
}
[HttpPost]
public ActionResult UnitCSR(FormCollection f)
{
//now get the individual form choices
ShowAllUnitCSRCriteriaModel model = new ShowAllUnitCSRCriteriaModel();
model.objectId = ay.parseGuid("hdObjectId", f);
model.filter = ay.parseBool("ckFilter", f);
model.maxRecords = f["plMaxRecords"];
model.createdDateRange = f["plCreatedDateRange"];
model.csrPriority = f["plPriority"];
model.csrStatus = f["plStatus"];
model.csrUnitId = ay.parseGuid("hdUnitId", f);
Session["ShowAllUnitCSRCriteriaModel"] = model;
return RedirectToAction("UnitCSR", new { UnitId=model.csrUnitId });
}
#endregion Show all unit CSR
//eoc
}
}