コード例 #1
0
        public ActionResult DeleteDocumentTypeRight(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 DocumentTypeRightServices().DeleteDocumentTypeRight(id);
                if (delStatus < 1)
                {
                    gVal.Code  = -1;
                    gVal.Error = "Document Right could not be deleted. Please try again later.";
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                gVal.Code  = 5;
                gVal.Error = "Document Right Information was successfully deleted";
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
        }
コード例 #2
0
        public ActionResult GetDocumentsRequirementObjects(JQueryDataTableParamModel param)
        {
            try
            {
                IEnumerable <DocumentTypeRightObject> filteredParentMenuObjects;
                int countG;

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

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

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

                //var sortColumnIndex = Convert.ToInt32(Request["iSortCol_0"]);
                Func <DocumentTypeRightObject, string> orderingFunction = (c => c.RoleName);

                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.RoleId), c.RoleName, c.DocumentTypeName };
                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 <DocumentsRequirementObject>(), JsonRequestBehavior.AllowGet));
            }
        }
コード例 #3
0
        public ActionResult EditDocumentTypeRight(List <DocumentTypeRightObject> newReqs)
        {
            var gVal = new GenericValidator();

            try
            {
                var validationResult = ValidateDocumentTypeRights(newReqs);

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

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

                var olddocumentTypeRights = Session["_documentTypeRights"] as List <DocumentTypeRightObject>;

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

                var docStatus = new DocumentTypeRightServices().UpdateDocumentTypeRights(olddocumentTypeRights, newReqs);
                if (docStatus < 1)
                {
                    gVal.Code  = -1;
                    gVal.Error = docStatus == -3 ? "Document Right already exists." : "Document Right information could not be updated. Please try again later";
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                gVal.Code  = 5;
                gVal.Error = "Process completed successfully";
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                gVal.Code  = -1;
                gVal.Error = "Document Right information could not be updated. Please try again later";
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
        }
コード例 #4
0
        public ActionResult GetDocumentTypeRight(string roleId)
        {
            try
            {
                var documentTypeRights = new DocumentTypeRightServices().GetDocumentRightsByRole(roleId);
                if (documentTypeRights == null || !documentTypeRights.Any())
                {
                    return(Json(new DocumentTypeRightObject(), JsonRequestBehavior.AllowGet));
                }

                Session["_documentTypeRights"] = documentTypeRights;

                return(Json(documentTypeRights, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                return(Json(new DocumentTypeRightObject(), JsonRequestBehavior.AllowGet));
            }
        }
コード例 #5
0
        public ActionResult AddDocumentTypeRight(List <DocumentTypeRightObject> documentTypeRights)
        {
            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 = ValidateDocumentTypeRights(documentTypeRights);

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

                var appStatus = new DocumentTypeRightServices().AddDocumentTypeRights(documentTypeRights);
                if (appStatus < 1)
                {
                    validationResult.Code  = -1;
                    validationResult.Error = appStatus == -2 ? "DocumentTypeRight upload failed. Please try again." : "The Document Right Information already exists";
                    return(Json(validationResult, JsonRequestBehavior.AllowGet));
                }

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