public long UpdateImportStage(ImportStageObject importStage) { try { if (importStage == null) { return(-2); } var importStageEntity = ModelMapper.Map <ImportStageObject, ImportStage>(importStage); if (importStageEntity == null || importStageEntity.Id < 1) { return(-2); } using (var db = new ImportPermitEntities()) { db.ImportStages.Attach(importStageEntity); db.Entry(importStageEntity).State = EntityState.Modified; db.SaveChanges(); return(importStage.Id); } } catch (Exception ex) { ErrorLogger.LoggError(ex.StackTrace, ex.Source, ex.Message); return(0); } }
public long AddImportStage(ImportStageObject importStage) { try { if (importStage == null) { return(-2); } var importStageEntity = ModelMapper.Map <ImportStageObject, ImportStage>(importStage); if (importStageEntity == null || string.IsNullOrEmpty(importStageEntity.Name)) { return(-2); } using (var db = new ImportPermitEntities()) { var returnStatus = db.ImportStages.Add(importStageEntity); db.SaveChanges(); return(returnStatus.Id); } } catch (Exception ex) { ErrorLogger.LoggError(ex.StackTrace, ex.Source, ex.Message); return(0); } }
public ActionResult EditImportStage(ImportStageObject ImportStage) { var gVal = new GenericValidator(); try { //if (!ModelState.IsValid) //{ // gVal.Code = -1; // gVal.Error = "Plese provide all required fields and try again."; // return Json(gVal, JsonRequestBehavior.AllowGet); //} if (string.IsNullOrEmpty(ImportStage.Name.Trim())) { gVal.Code = -1; gVal.Error = "Please provide Application Stage."; return(Json(gVal, JsonRequestBehavior.AllowGet)); } if (Session["_ImportStage"] == null) { gVal.Code = -1; gVal.Error = "Session has timed out."; return(Json(gVal, JsonRequestBehavior.AllowGet)); } var oldImportStage = Session["_ImportStage"] as ImportStageObject; if (oldImportStage == null) { gVal.Code = -1; gVal.Error = "Session has timed out."; return(Json(gVal, JsonRequestBehavior.AllowGet)); } oldImportStage.Name = ImportStage.Name.Trim(); var docStatus = new ImportStageServices().UpdateImportStage(oldImportStage); if (docStatus < 1) { gVal.Code = -1; gVal.Error = "Application Stage information could not be updated. Please try again later"; return(Json(gVal, JsonRequestBehavior.AllowGet)); } gVal.Code = oldImportStage.Id; gVal.Error = "Application Stage information was successfully updated"; return(Json(gVal, JsonRequestBehavior.AllowGet)); } catch (Exception) { gVal.Code = -1; gVal.Error = "Application Stage information could not be updated. Please try again later"; return(Json(gVal, JsonRequestBehavior.AllowGet)); } }
public long UpdateImportStage(ImportStageObject applicationStage) { try { return(_applicationStageManager.UpdateImportStage(applicationStage)); } catch (Exception ex) { ErrorLogger.LoggError(ex.StackTrace, ex.Source, ex.Message); return(0); } }
public ActionResult AddImportStage(ImportStageObject ImportStage) { var gVal = new GenericValidator(); try { //if (!ModelState.IsValid) //{ // gVal.Code = -1; // gVal.Error = "Plese provide all required fields and try again."; // return Json(gVal, JsonRequestBehavior.AllowGet); //} var importerInfo = GetLoggedOnUserInfo(); if (importerInfo.Id < 1) { gVal.Error = "Your session has timed out"; gVal.Code = -1; return(Json(gVal, JsonRequestBehavior.AllowGet)); } var validationResult = ValidateImportStage(ImportStage); if (validationResult.Code == 1) { return(Json(validationResult, JsonRequestBehavior.AllowGet)); } var appStatus = new ImportStageServices().AddImportStage(ImportStage); if (appStatus < 1) { validationResult.Code = -1; validationResult.Error = appStatus == -2 ? "ImportStage upload failed. Please try again." : "The Application Stage Information already exists"; return(Json(validationResult, JsonRequestBehavior.AllowGet)); } gVal.Code = appStatus; gVal.Error = "Application Stage was successfully added."; return(Json(gVal, JsonRequestBehavior.AllowGet)); } catch (Exception) { gVal.Error = "Application Stage processing failed. Please try again later"; gVal.Code = -1; return(Json(gVal, JsonRequestBehavior.AllowGet)); } }
private GenericValidator ValidateImportStage(ImportStageObject ImportStage) { var gVal = new GenericValidator(); try { if (string.IsNullOrEmpty(ImportStage.Name)) { gVal.Code = -1; gVal.Error = "Please select provide Application Stage."; return(gVal); } gVal.Code = 5; return(gVal); } catch (Exception) { gVal.Code = -1; gVal.Error = "Application Stage Validation failed. Please provide all required fields and try again."; return(gVal); } }