public ActionResult DeleteImportClassificationRequirement(long id)
        {
            var gVal = new GenericValidator();

            try
            {
                if (id < 1)
                {
                    gVal.Code  = -1;
                    gVal.Error = "Invalid selection";
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }
                var delStatus = new ImportClassificationRequirementServices().DeleteImportClassificationRequirement(id);
                if (delStatus < 1)
                {
                    gVal.Code  = -1;
                    gVal.Error = "Import Classification could not be deleted. Please try again later.";
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                gVal.Code  = 5;
                gVal.Error = "Import Classification Information was successfully deleted";
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
        }
        public ActionResult GetImportClassificationRequirementObjects(JQueryDataTableParamModel param)
        {
            try
            {
                IEnumerable <ImportClassificationRequirementObject> filteredParentMenuObjects;
                int countG;

                var pagedParentMenuObjects = GetImportClassificationRequirements(param.iDisplayLength, param.iDisplayStart, out countG);

                if (!string.IsNullOrEmpty(param.sSearch))
                {
                    filteredParentMenuObjects = new ImportClassificationRequirementServices().Search(param.sSearch);
                }
                else
                {
                    filteredParentMenuObjects = pagedParentMenuObjects;
                }

                if (!filteredParentMenuObjects.Any())
                {
                    return(Json(new List <ImportClassificationRequirementObject>(), JsonRequestBehavior.AllowGet));
                }

                var sortColumnIndex = Convert.ToInt32(Request["iSortCol_0"]);
                Func <ImportClassificationRequirementObject, string> orderingFunction = (c => sortColumnIndex == 1 ? c.ImportClassName : c.ImportStageName);

                var sortDirection = Request["sSortDir_0"]; // asc or desc
                filteredParentMenuObjects = sortDirection == "desc" ? filteredParentMenuObjects.OrderBy(orderingFunction) : filteredParentMenuObjects.OrderByDescending(orderingFunction);

                var displayedPersonnels = filteredParentMenuObjects;

                var result = from c in displayedPersonnels
                             select new[] { Convert.ToString(c.Id), c.ImportClassName, c.ImportStageName, c.Requirements };
                return(Json(new
                {
                    param.sEcho,
                    iTotalRecords = countG,
                    iTotalDisplayRecords = countG,
                    aaData = result
                },
                            JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                ErrorLogger.LoggError(ex.StackTrace, ex.Source, ex.Message);
                return(Json(new List <ImportClassificationRequirementObject>(), JsonRequestBehavior.AllowGet));
            }
        }
        public ActionResult EditImportClassificationRequirement(List <ImportClassificationRequirementObject> importClassificationRequirements)
        {
            var gVal = new GenericValidator();

            try
            {
                var stat = ValidateImportClassificationRequirement(importClassificationRequirements);

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

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

                var oldimportClassificationRequirement = Session["_classificationReq"] as ImportClassificationRequirementObject;

                if (oldimportClassificationRequirement == null)
                {
                    gVal.Code  = -1;
                    gVal.Error = "Session has timed out.";
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }
                var docStatus = new ImportClassificationRequirementServices().UpdateImportClassificationRequirement(oldimportClassificationRequirement, importClassificationRequirements);
                if (docStatus < 1)
                {
                    gVal.Code  = -1;
                    gVal.Error = docStatus == -3 ? "Import Classification already exists." : "Import Classification Requirement could not be updated. Please try again later";
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                gVal.Code  = oldimportClassificationRequirement.Id;
                gVal.Error = "Import Classification Requirement was successfully updated";
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                gVal.Code  = -1;
                gVal.Error = "Import Classification Requirement could not be updated. Please try again later";
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
        }
        public ActionResult GetImportClassificationRequirement(long id)
        {
            try
            {
                var importClassificationRequirement = new ImportClassificationRequirementServices().GetImportClassificationRequirement(id);
                if (importClassificationRequirement == null || importClassificationRequirement.Id < 1)
                {
                    return(Json(new ImportClassificationRequirementObject(), JsonRequestBehavior.AllowGet));
                }

                Session["_classificationReq"] = importClassificationRequirement;

                return(Json(importClassificationRequirement, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                return(Json(new ImportClassificationRequirementObject(), JsonRequestBehavior.AllowGet));
            }
        }
        public ActionResult AddImportClassificationRequirement(List <ImportClassificationRequirementObject> importClassificationRequirements)
        {
            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 = ValidateImportClassificationRequirement(importClassificationRequirements);

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

                var appStatus = new ImportClassificationRequirementServices().AddImportClassificationRequirement(importClassificationRequirements);
                if (appStatus < 1)
                {
                    validationResult.Code  = -1;
                    validationResult.Error = appStatus == -2 ? "ImportClassificationRequirement upload failed. Please try again." : "The Import Classification Information already exists";
                    return(Json(validationResult, JsonRequestBehavior.AllowGet));
                }

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