[HttpPost, ActionName("deletePCA")] //This action MUST match the above delete function. public virtual ActionResult confirmDeletePCA(int id) { Authentication auth = new Authentication(); if (auth.isAdmin(this) || Authentication.DEBUG_bypassAuth) { //make sure there are no work efforts attached to the PCA if (checkPcaForAttachedWorkEfforts(id) == true) { TempData["failedPcaDelete"] = true; return(RedirectToAction("maintainPCA")); } else { PcaCode pcacode = PcaCodeDB.PcaCodeList.Find(id); PcaCodeDB.PcaCodeList.Remove(pcacode); PcaCodeDB.SaveChanges(); return(RedirectToAction("maintainPCA")); } } else { return(View("error")); } }
public virtual ActionResult addPCA(PcaCode pcacode) { Authentication auth = new Authentication(); if (auth.isAdmin(this) || Authentication.DEBUG_bypassAuth) { if (ModelState.IsValid) { if (pcacode.endDate == null) { pcacode.endDate = DateTime.MaxValue; } //make sure the start date is before the end date if (pcacode.startDate > pcacode.endDate) { ViewBag.endBeforeStartFlag = true; ViewBag.divisionList = getDivisionSelectList(); return(View(pcacode)); } /* Make sure that the dates don't overlap if there is another PCA with the same * code in the same division */ if (pcaCheckIfDuplicate(pcacode) == false) { PcaCodeDB.PcaCodeList.Add(pcacode); PcaCodeDB.SaveChanges(); return(RedirectToAction("maintainPCA")); } else { ViewBag.duplicatePcaFlag = true; ViewBag.divisionList = getDivisionSelectList(); return(View(pcacode)); } } return(View(pcacode)); } else { return(View("error")); } }
public virtual ActionResult confirmEditPCA(PcaCode pcacode) { Authentication auth = new Authentication(); if (auth.isAdmin(this) || Authentication.DEBUG_bypassAuth) { if (ModelState.IsValid) { PcaCodeDB.PcaCodeList.Add(pcacode); PcaCodeDB.Entry(pcacode).State = System.Data.EntityState.Modified; PcaCodeDB.SaveChanges(); } return(RedirectToAction("maintainPCA")); } else { return(View("error")); } }
// //This was attached to delete; not sure what this is yet, but it doesn't explode! protected override void Dispose(bool disposing) { PcaCodeDB.Dispose(); base.Dispose(disposing); }