Esempio n. 1
0
        public long UpdateJetty(JettyObject jetty)
        {
            try
            {
                if (jetty == null)
                {
                    return(-2);
                }

                var jettyEntity = ModelMapper.Map <JettyObject, Jetty>(jetty);
                if (jettyEntity == null || jettyEntity.Id < 1)
                {
                    return(-2);
                }

                using (var db = new ImportPermitEntities())
                {
                    db.Jetties.Attach(jettyEntity);
                    db.Entry(jettyEntity).State = EntityState.Modified;
                    db.SaveChanges();
                    return(jetty.Id);
                }
            }
            catch (Exception ex)
            {
                ErrorLogger.LoggError(ex.StackTrace, ex.Source, ex.Message);
                return(0);
            }
        }
Esempio n. 2
0
        public long AddJetty(JettyObject jetty)
        {
            try
            {
                if (jetty == null)
                {
                    return(-2);
                }



                using (var db = new ImportPermitEntities())
                {
                    var jettyEntity = new Jetty
                    {
                        Name   = jetty.Name,
                        PortId = jetty.PortId
                    };
                    var returnStatus = db.Jetties.Add(jettyEntity);
                    db.SaveChanges();
                    return(returnStatus.Id);
                }
            }
            catch (Exception ex)
            {
                ErrorLogger.LoggError(ex.StackTrace, ex.Source, ex.Message);
                return(0);
            }
        }
Esempio n. 3
0
        private GenericValidator ValidateJetty(JettyObject jetty)
        {
            var gVal = new GenericValidator();

            try
            {
                if (jetty.PortId < 1)
                {
                    gVal.Code  = -1;
                    gVal.Error = "Please select a Port.";
                    return(gVal);
                }



                gVal.Code = 5;
                return(gVal);
            }
            catch (Exception)
            {
                gVal.Code  = -1;
                gVal.Error = "Jetty Validation failed. Please provide all required fields and try again.";
                return(gVal);
            }
        }
Esempio n. 4
0
 public long UpdateJetty(JettyObject jetty)
 {
     try
     {
         return(_jettyManager.UpdateJetty(jetty));
     }
     catch (Exception ex)
     {
         ErrorLogger.LoggError(ex.StackTrace, ex.Source, ex.Message);
         return(0);
     }
 }
Esempio n. 5
0
        public ActionResult EditJetty(JettyObject jetty)
        {
            var gVal = new GenericValidator();

            try
            {
                var stat = ValidateJetty(jetty);

                if (stat.Code < 1)
                {
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                if (Session["_jetty"] == null)
                {
                    gVal.Code  = -1;
                    gVal.Error = "Session has timed out.";
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                var oldjetty = Session["_jetty"] as JettyObject;

                if (oldjetty == null)
                {
                    gVal.Code  = -1;
                    gVal.Error = "Session has timed out.";
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                oldjetty.Name   = jetty.Name;
                oldjetty.PortId = jetty.PortId;

                var docStatus = new JettyServices().UpdateJetty(oldjetty);
                if (docStatus < 1)
                {
                    gVal.Code  = -1;
                    gVal.Error = docStatus == -3 ? "Jetty already exists." : "Jetty information could not be updated. Please try again later";
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                gVal.Code  = oldjetty.Id;
                gVal.Error = "Jetty information was successfully updated";
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                gVal.Code  = -1;
                gVal.Error = "Jetty information could not be updated. Please try again later";
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
        }
Esempio n. 6
0
        public ActionResult AddJetty(JettyObject jetty)
        {
            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 = ValidateJetty(jetty);

                if (validationResult.Code == 1)
                {
                    return(Json(validationResult, JsonRequestBehavior.AllowGet));
                }


                var appStatus = new JettyServices().AddJetty(jetty);
                if (appStatus < 1)
                {
                    validationResult.Code  = -1;
                    validationResult.Error = appStatus == -2 ? "Jetty upload failed. Please try again." : "The Jetty Information already exists";
                    return(Json(validationResult, JsonRequestBehavior.AllowGet));
                }

                gVal.Code  = appStatus;
                gVal.Error = "Jetty was successfully added.";
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                gVal.Error = "Jetty processing failed. Please try again later";
                gVal.Code  = -1;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
        }