private GenericValidator ValidateJettyMapping(JettyMappingObject jettyMapping) { var gVal = new GenericValidator(); try { if (jettyMapping.JettyId < 1) { gVal.Code = -1; gVal.Error = "Please select a Jetty."; return(gVal); } if (jettyMapping.ZoneId < 1) { gVal.Code = -1; gVal.Error = "Please select a Zone."; return(gVal); } gVal.Code = 5; return(gVal); } catch (Exception) { gVal.Code = -1; gVal.Error = "JettyMapping Validation failed. Please provide all required fields and try again."; return(gVal); } }
public long UpdateJettyMapping(JettyMappingObject jettyMapping) { try { if (jettyMapping == null) { return(-2); } var jettyMappingEntity = ModelMapper.Map <JettyMappingObject, JettyMapping>(jettyMapping); if (jettyMappingEntity == null || jettyMappingEntity.Id < 1) { return(-2); } using (var db = new ImportPermitEntities()) { db.JettyMappings.Attach(jettyMappingEntity); db.Entry(jettyMappingEntity).State = EntityState.Modified; db.SaveChanges(); return(jettyMapping.Id); } } catch (Exception ex) { ErrorLogger.LoggError(ex.StackTrace, ex.Source, ex.Message); return(0); } }
public long AddJettyMapping(JettyMappingObject jettyMapping) { try { if (jettyMapping == null) { return(-2); } using (var db = new ImportPermitEntities()) { var jettyMappingEntity = new JettyMapping { JettyId = jettyMapping.JettyId, ZoneId = jettyMapping.ZoneId }; var returnStatus = db.JettyMappings.Add(jettyMappingEntity); db.SaveChanges(); return(returnStatus.Id); } } catch (Exception ex) { ErrorLogger.LoggError(ex.StackTrace, ex.Source, ex.Message); return(0); } }
public long UpdateJettyMapping(JettyMappingObject jettyMapping) { try { return(_jettyMappingManager.UpdateJettyMapping(jettyMapping)); } catch (Exception ex) { ErrorLogger.LoggError(ex.StackTrace, ex.Source, ex.Message); return(0); } }
public ActionResult EditJettyMapping(JettyMappingObject jettyMapping) { var gVal = new GenericValidator(); try { var stat = ValidateJettyMapping(jettyMapping); if (stat.Code < 1) { return(Json(gVal, JsonRequestBehavior.AllowGet)); } if (Session["_jettyMapping"] == null) { gVal.Code = -1; gVal.Error = "Session has timed out."; return(Json(gVal, JsonRequestBehavior.AllowGet)); } var oldjettyMapping = Session["_jettyMapping"] as JettyMappingObject; if (oldjettyMapping == null) { gVal.Code = -1; gVal.Error = "Session has timed out."; return(Json(gVal, JsonRequestBehavior.AllowGet)); } oldjettyMapping.JettyId = jettyMapping.JettyId; oldjettyMapping.ZoneId = jettyMapping.ZoneId; var docStatus = new JettyMappingServices().UpdateJettyMapping(oldjettyMapping); if (docStatus < 1) { gVal.Code = -1; gVal.Error = docStatus == -3 ? "JettyMapping already exists." : "JettyMapping information could not be updated. Please try again later"; return(Json(gVal, JsonRequestBehavior.AllowGet)); } gVal.Code = oldjettyMapping.Id; gVal.Error = "JettyMapping information was successfully updated"; return(Json(gVal, JsonRequestBehavior.AllowGet)); } catch (Exception) { gVal.Code = -1; gVal.Error = "JettyMapping information could not be updated. Please try again later"; return(Json(gVal, JsonRequestBehavior.AllowGet)); } }
public ActionResult AddJettyMapping(JettyMappingObject jettyMapping) { var gVal = new GenericValidator(); try { var importerInfo = GetLoggedOnUserInfo(); if (importerInfo.Id < 1) { gVal.Error = "Your session has timed out"; gVal.Code = -1; return(Json(gVal, JsonRequestBehavior.AllowGet)); } var validationResult = ValidateJettyMapping(jettyMapping); if (validationResult.Code == 1) { return(Json(validationResult, JsonRequestBehavior.AllowGet)); } var appStatus = new JettyMappingServices().AddJettyMapping(jettyMapping); if (appStatus < 1) { validationResult.Code = -1; validationResult.Error = appStatus == -2 ? "JettyMapping upload failed. Please try again." : "The JettyMapping Information already exists"; return(Json(validationResult, JsonRequestBehavior.AllowGet)); } gVal.Code = appStatus; gVal.Error = "JettyMapping was successfully added."; return(Json(gVal, JsonRequestBehavior.AllowGet)); } catch (Exception) { gVal.Error = "JettyMapping processing failed. Please try again later"; gVal.Code = -1; return(Json(gVal, JsonRequestBehavior.AllowGet)); } }