104 lines
3.3 KiB
C#
104 lines
3.3 KiB
C#
using System;
|
|
using System.Web.Mvc;
|
|
using GZTW.AyaNova.BLL;
|
|
using ri.util;
|
|
|
|
namespace ri.Controllers
|
|
{
|
|
public class ServiceBankController : Controller
|
|
{
|
|
|
|
#region List
|
|
//
|
|
// GET: /ServiceBank/
|
|
|
|
public ActionResult Index(Guid Id, int aytype)
|
|
{
|
|
|
|
ViewBag.newItemUrl = ay.genBaseSiteUrl(Url) + "ServiceBank/Create?id=" + Id.ToString() + "&aytype=" + aytype.ToString();
|
|
ViewBag.objectId = Id;
|
|
ViewBag.titleName = NameFetcher.GetItem((RootObjectTypes)aytype, Id, true).RecordName;
|
|
formInit();
|
|
//NO MENU FOR LIST
|
|
return View();
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region Create
|
|
//
|
|
// GET: /ServiceBank/Create
|
|
public ActionResult Create(Guid Id, int aytype)
|
|
{
|
|
//display the form for creating
|
|
formInit();
|
|
ViewBag.objectId = Id;
|
|
ViewBag.objectType = aytype;
|
|
|
|
ServiceBank sb = ServiceBank.NewItem();
|
|
sb.AppliesToRootObjectType = (RootObjectTypes)aytype;
|
|
sb.AppliesToRootObjectID = Id;
|
|
sb.SourceRootObjectType = RootObjectTypes.ServiceBank;
|
|
sb.SourceRootObjectID = Guid.Empty;
|
|
ViewBag.titleName = NameFetcher.GetItem((RootObjectTypes)aytype, Id, true).RecordName;
|
|
return View(sb);
|
|
}
|
|
|
|
|
|
//
|
|
// POST: /Memo/Create
|
|
[HttpPost]
|
|
public ActionResult Create(FormCollection f)
|
|
{
|
|
try
|
|
{
|
|
ServiceBank c = ServiceBank.NewItem();
|
|
c.AppliesToRootObjectType = (RootObjectTypes)(int.Parse(f["ayObjectType"]));
|
|
c.AppliesToRootObjectID = new Guid(f["ayObjectId"]);
|
|
c.SourceRootObjectType = RootObjectTypes.ServiceBank;
|
|
c.SourceRootObjectID = Guid.Empty;
|
|
c.Description=ay.ParseMultiLineText("Description", f);
|
|
c.Currency=ay.parseDecimal("Currency",f);
|
|
c.Hours=ay.parseDecimal("Hours",f);
|
|
c.Incidents=ay.parseDecimal("Incidents",f);
|
|
c.EffectiveDate=ay.ParseDateToDbValue("EffectiveDate", f);
|
|
|
|
if (c.IsSavable)
|
|
c.Save();
|
|
else
|
|
{
|
|
//Broken rules
|
|
ayBrokenRules rulesError = new ayBrokenRules(c);
|
|
ViewBag.err = rulesError;
|
|
return Redirect(f["ayRetUrl"]);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ay.setGeneralError(TempData, ex);
|
|
//May not need a custom menu for this so for now keep out
|
|
//formInit(c);
|
|
return Redirect(f["ayRetUrl"]);
|
|
|
|
}
|
|
|
|
return Redirect(f["ayRetUrl"]);
|
|
}
|
|
#endregion create
|
|
|
|
#region Menu and rights
|
|
|
|
private void formInit()
|
|
{
|
|
//NO MENU FOR SERVICE BANK ITEM
|
|
//(can't delete, can't view - only create so no history etc)
|
|
|
|
//set rights
|
|
util.ay.setViewBagRights(ViewBag, RootObjectTypes.ServiceBank);
|
|
|
|
}
|
|
#endregion
|
|
|
|
}//eoc
|
|
}//ens
|