public ActionResult Delete(LookupEditorViewModel lookupEditorViewModel) { questStatus status = null; /*---------------------------------------------------------------------------------------------------------------------------------- * Log Operation *---------------------------------------------------------------------------------------------------------------------------------*/ status = LogOperation(); if (!questStatusDef.IsSuccess(status)) { // TODO throw new Exception("LogOperation failed"); } /*---------------------------------------------------------------------------------------------------------------------------------- * Authorize *---------------------------------------------------------------------------------------------------------------------------------*/ status = Authorize(lookupEditorViewModel._ctx); if (!questStatusDef.IsSuccess(status)) { // TODO throw new Exception("Authorize failed"); } /*---------------------------------------------------------------------------------------------------------------------------------- * Perform operation. *---------------------------------------------------------------------------------------------------------------------------------*/ LookupId lookupId = new LookupId(lookupEditorViewModel.Id); LookupEditorModeler lookupEditorModeler = new LookupEditorModeler(this.Request, this.UserSession); status = lookupEditorModeler.Delete(lookupId); if (!questStatusDef.IsSuccess(status)) { lookupEditorViewModel.questStatus = status; return(Json(lookupEditorViewModel, JsonRequestBehavior.AllowGet)); } /*---------------------------------------------------------------------------------------------------------------------------------- * Return result. *---------------------------------------------------------------------------------------------------------------------------------*/ status = new questStatus(Severity.Success, "Lookup successfully deleted"); lookupEditorViewModel.questStatus = status; return(Json(lookupEditorViewModel, JsonRequestBehavior.AllowGet)); }
public ActionResult Save(LookupEditorViewModel lookupEditorViewModel) { questStatus status = null; /*---------------------------------------------------------------------------------------------------------------------------------- * Log Operation *---------------------------------------------------------------------------------------------------------------------------------*/ status = LogOperation(); if (!questStatusDef.IsSuccess(status)) { lookupEditorViewModel.questStatus = status; return(Json(lookupEditorViewModel, JsonRequestBehavior.AllowGet)); } /*---------------------------------------------------------------------------------------------------------------------------------- * Authorize *---------------------------------------------------------------------------------------------------------------------------------*/ status = Authorize(lookupEditorViewModel._ctx); if (!questStatusDef.IsSuccess(status)) { lookupEditorViewModel.questStatus = status; return(Json(lookupEditorViewModel, JsonRequestBehavior.AllowGet)); } /*---------------------------------------------------------------------------------------------------------------------------------- * Perform operation. *---------------------------------------------------------------------------------------------------------------------------------*/ bool bInitialCreation = lookupEditorViewModel.Id < BaseId.VALID_ID ? true : false; LookupEditorModeler lookupEditorModeler = new LookupEditorModeler(this.Request, this.UserSession); status = lookupEditorModeler.Save(lookupEditorViewModel); if (!questStatusDef.IsSuccess(status)) { lookupEditorViewModel.questStatus = status; return(Json(lookupEditorViewModel, JsonRequestBehavior.AllowGet)); } /*---------------------------------------------------------------------------------------------------------------------------------- * Return result. *---------------------------------------------------------------------------------------------------------------------------------*/ status = new questStatus(Severity.Success, "Lookup successfully" + (bInitialCreation ? " created" : " updated")); lookupEditorViewModel.questStatus = status; return(Json(lookupEditorViewModel, JsonRequestBehavior.AllowGet)); }