Example #1
0
        public long UpdateRecertification(RecertificationObject recertification)
        {
            try
            {
                if (recertification == null)
                {
                    return(-2);
                }

                var recertificationEntity = ModelMapper.Map <RecertificationObject, Recertification>(recertification);
                if (recertificationEntity == null || recertificationEntity.Id < 1)
                {
                    return(-2);
                }

                using (var db = new ImportPermitEntities())
                {
                    db.Recertifications.Attach(recertificationEntity);
                    db.Entry(recertificationEntity).State = EntityState.Modified;
                    db.SaveChanges();
                    return(recertification.Id);
                }
            }
            catch (Exception ex)
            {
                ErrorLogger.LoggError(ex.StackTrace, ex.Source, ex.Message);
                return(0);
            }
        }
Example #2
0
        //public List<RecertificationObject> GetLocalRecertifications()
        //{
        //    try
        //    {
        //        using (var db = new ImportPermitEntities())
        //        {
        //            const int nigeria = (int) CountryEnum.Nigeria;

        //            var recertifications = db.Recertifications.Where(c => c.Jetty.Port.Country.Name == "nigeria").ToList();

        //            if (!recertifications.Any())
        //            {
        //                return new List<RecertificationObject>();
        //            }

        //            var objList = new List<RecertificationObject>();

        //            recertifications.ForEach(app =>
        //            {


        //                    var recertificationObject = ModelMapper.Map<Recertification, RecertificationObject>(app);
        //                    if (recertificationObject != null && recertificationObject.Id > 0)
        //                    {
        //                       objList.Add(recertificationObject);
        //                    }

        //           });

        //            return !objList.Any() ? new List<RecertificationObject>() : objList;
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        ErrorLogger.LoggError(ex.StackTrace, ex.Source, ex.Message);
        //        return null;
        //    }
        //}
        public List <RecertificationObject> GetRecertifications()
        {
            try
            {
                using (var db = new ImportPermitEntities())
                {
                    var objList = new List <RecertificationObject>();


                    var recertifications = db.Recertifications.ToList();

                    foreach (var item in recertifications)
                    {
                        var recertificationObj = new RecertificationObject();
                        recertificationObj.ReferenceCode = item.ReferenceCode;
                        recertificationObj.Id            = item.Id;
                        recertificationObj.StatusStr     = Enum.GetName(typeof(RecertificationStatusEnum), item.Status);

                        objList.Add(recertificationObj);
                    }

                    return(objList);
                }
            }
            catch (Exception ex)
            {
                ErrorLogger.LoggError(ex.StackTrace, ex.Source, ex.Message);
                return(new List <RecertificationObject>());
            }
        }
Example #3
0
        private GenericValidator ValidateRecertification(RecertificationObject recertification)
        {
            var gVal = new GenericValidator();

            try
            {
                if (recertification.Id < 1)
                {
                    gVal.Code  = -1;
                    gVal.Error = "Please select a Recertification.";
                    return(gVal);
                }



                gVal.Code = 5;
                return(gVal);
            }
            catch (Exception)
            {
                gVal.Code  = -1;
                gVal.Error = "Recertification Validation failed. Please provide all required fields and try again.";
                return(gVal);
            }
        }
 public long UpdateRecertification(RecertificationObject Recertification)
 {
     try
     {
         return(_RecertificationManager.UpdateRecertification(Recertification));
     }
     catch (Exception ex)
     {
         ErrorLogger.LoggError(ex.StackTrace, ex.Source, ex.Message);
         return(0);
     }
 }
Example #5
0
        public ActionResult EditRecertification(RecertificationObject recertification)
        {
            var gVal = new GenericValidator();

            try
            {
                var stat = ValidateRecertification(recertification);

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

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

                var oldrecertification = Session["_recertification"] as RecertificationObject;

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

                //oldrecertification.Name = recertification.Name;
                //oldrecertification.RecertificationOwnerId = recertification.RecertificationOwnerId;
                //oldrecertification.JettyId = recertification.JettyId;

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

                gVal.Code  = oldrecertification.Id;
                gVal.Error = "Recertification information was successfully updated";
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                gVal.Code  = -1;
                gVal.Error = "Recertification information could not be updated. Please try again later";
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
        }
Example #6
0
        public long AddRecertification(RecertificationObject recertification)
        {
            try
            {
                if (recertification == null)
                {
                    return(-2);
                }



                using (var db = new ImportPermitEntities())
                {
                    var not    = db.Notifications.Where(n => n.Id == recertification.Id).ToList();
                    var recert = new Recertification();

                    if (not.Any())
                    {
                        recert.NotificationId = not[0].Id;
                        recert.DateApplied    = DateTime.Now;
                        recert.Status         = (int)RecertificationStatusEnum.Processing;
                        recert.ReferenceCode  = not[0].Invoice.ReferenceCode;
                        recert.LastModified   = DateTime.Now;
                        db.Recertifications.Add(recert);
                        //change the status of the notification
                        not[0].Status = (int)NotificationStatusEnum.Recertifying;
                        db.Notifications.Attach(not[0]);
                        db.Entry(not[0]).State = EntityState.Modified;
                        db.SaveChanges();
                        //add to process tracking
                        AssignRecertificationToEmployee(recert.Id);
                        return(1);
                    }

                    return(0);
                }
            }
            catch (Exception ex)
            {
                ErrorLogger.LoggError(ex.StackTrace, ex.Source, ex.Message);
                return(0);
            }
        }
Example #7
0
        public ActionResult AddRecertification(RecertificationObject recertification)
        {
            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 = ValidateRecertification(recertification);

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


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

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