public long UpdateNotificationInspectionQueue(NotificationInspectionQueueObject notificationInspectionQueue)
        {
            try
            {
                if (notificationInspectionQueue == null)
                {
                    return(-2);
                }

                var notificationInspectionQueueEntity = ModelMapper.Map <NotificationInspectionQueueObject, NotificationInspectionQueue>(notificationInspectionQueue);
                if (notificationInspectionQueueEntity == null || notificationInspectionQueueEntity.Id < 1)
                {
                    return(-2);
                }

                using (var db = new ImportPermitEntities())
                {
                    db.NotificationInspectionQueues.Attach(notificationInspectionQueueEntity);
                    db.Entry(notificationInspectionQueueEntity).State = EntityState.Modified;
                    db.SaveChanges();
                    return(notificationInspectionQueue.Id);
                }
            }
            catch (Exception ex)
            {
                ErrorLogger.LoggError(ex.StackTrace, ex.Source, ex.Message);
                return(0);
            }
        }
        public long AddNotificationInspectionQueue(NotificationInspectionQueueObject notificationInspectionQueue)
        {
            try
            {
                if (notificationInspectionQueue == null)
                {
                    return(-2);
                }

                var notificationInspectionQueueEntity = ModelMapper.Map <NotificationInspectionQueueObject, NotificationInspectionQueue>(notificationInspectionQueue);
                if (notificationInspectionQueueEntity == null || string.IsNullOrEmpty(notificationInspectionQueueEntity.Notification.Invoice.ReferenceCode))
                {
                    return(-2);
                }
                using (var db = new ImportPermitEntities())
                {
                    var returnStatus = db.NotificationInspectionQueues.Add(notificationInspectionQueueEntity);
                    db.SaveChanges();
                    return(returnStatus.Id);
                }
            }
            catch (Exception ex)
            {
                ErrorLogger.LoggError(ex.StackTrace, ex.Source, ex.Message);
                return(0);
            }
        }
        public ActionResult EditNotificationInspectionQueue(NotificationInspectionQueueObject notificationInspectionQueue)
        {
            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(notificationInspectionQueue.ReferenceCode.Trim()))
                {
                    gVal.Code  = -1;
                    gVal.Error = "Please provide NotificationInspectionQueue.";
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

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

                var oldNotificationInspectionQueue = Session["_NotificationInspectionQueue"] as NotificationInspectionQueueObject;

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


                oldNotificationInspectionQueue.ReferenceCode = notificationInspectionQueue.ReferenceCode.Trim();

                var docStatus = new NotificationInspectionQueueServices().UpdateNotificationInspectionQueue(oldNotificationInspectionQueue);
                if (docStatus < 1)
                {
                    gVal.Code  = -1;
                    gVal.Error = "NotificationInspectionQueue information could not be updated. Please try again later";
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                gVal.Code  = oldNotificationInspectionQueue.Id;
                gVal.Error = "NotificationInspectionQueue information was successfully updated";
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                gVal.Code  = -1;
                gVal.Error = "NotificationInspectionQueue information could not be updated. Please try again later";
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
        }
Example #4
0
 public long UpdateNotificationInspectionQueue(NotificationInspectionQueueObject notificationInspectionQueue)
 {
     try
     {
         return(_notificationInspectionQueueManager.UpdateNotificationInspectionQueue(notificationInspectionQueue));
     }
     catch (Exception ex)
     {
         ErrorLogger.LoggError(ex.StackTrace, ex.Source, ex.Message);
         return(0);
     }
 }
        public ActionResult AddNotificationInspectionQueue(NotificationInspectionQueueObject notificationInspectionQueue)
        {
            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 = ValidateNotificationInspectionQueue(notificationInspectionQueue);

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

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

                gVal.Code  = appStatus;
                gVal.Error = "NotificationInspectionQueue was successfully added.";
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                gVal.Error = "NotificationInspectionQueue notificationInspectionQueueing failed. Please try again later";
                gVal.Code  = -1;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
        }
        private GenericValidator ValidateNotificationInspectionQueue(NotificationInspectionQueueObject notificationInspectionQueue)
        {
            var gVal = new GenericValidator();

            try
            {
                if (string.IsNullOrEmpty(notificationInspectionQueue.ReferenceCode))
                {
                    gVal.Code  = -1;
                    gVal.Error = "Please select provide NotificationInspectionQueue.";
                    return(gVal);
                }


                gVal.Code = 5;
                return(gVal);
            }
            catch (Exception)
            {
                gVal.Code  = -1;
                gVal.Error = "NotificationInspectionQueue Validation failed. Please provide all required fields and try again.";
                return(gVal);
            }
        }