Esempio n. 1
0
        public ActionResult DeleteFeeType(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 FeeTypeServices().DeleteFeeType(id);
                if (delStatus < 1)
                {
                    gVal.Code  = -1;
                    gVal.Error = "Fee Type could not be deleted. Please try again later.";
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                gVal.Code  = 5;
                gVal.Error = "Fee Type Information was successfully deleted";
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
        }
Esempio n. 2
0
        public ActionResult EditFeeType(FeeTypeObject feeType)
        {
            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 stat = ValidateFeeType(feeType);

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

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

                var oldfeeType = Session["_feeType"] as FeeTypeObject;

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

                oldfeeType.Name        = feeType.Name.Trim();
                oldfeeType.Description = feeType.Description;
                var docStatus = new FeeTypeServices().UpdateFeeType(oldfeeType);
                if (docStatus < 1)
                {
                    gVal.Code  = -1;
                    gVal.Error = docStatus == -3 ? "Fee Type already exists." : "Fee Type information could not be updated. Please try again later";
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                gVal.Code  = oldfeeType.FeeTypeId;
                gVal.Error = "Fee Type information was successfully updated";
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                gVal.Code  = -1;
                gVal.Error = "Fee Type information could not be updated. Please try again later";
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
        }
Esempio n. 3
0
        public ActionResult GetFeeTypeObjects(JQueryDataTableParamModel param)
        {
            try
            {
                IEnumerable <FeeTypeObject> filteredParentMenuObjects;
                var countG = 0;

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

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

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

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

                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.FeeTypeId), c.Name };
                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 <FeeTypeObject>(), JsonRequestBehavior.AllowGet));
            }
        }
Esempio n. 4
0
        public ActionResult AddFeeType(FeeTypeObject feeType)
        {
            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 = ValidateFeeType(feeType);

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

                var appStatus = new FeeTypeServices().AddFeeType(feeType);
                if (appStatus < 1)
                {
                    validationResult.Code  = -1;
                    validationResult.Error = appStatus == -2 ? "Fee Type could not be added. Please try again." : "The Fee Type Information already exists";
                    return(Json(validationResult, JsonRequestBehavior.AllowGet));
                }

                gVal.Code  = appStatus;
                gVal.Error = "Fee Type was successfully added.";
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                gVal.Error = "Fee Type processing failed. Please try again later";
                gVal.Code  = -1;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
        }
Esempio n. 5
0
        public ActionResult GetFeeType(long id)
        {
            try
            {
                var feeType = new FeeTypeServices().GetFeeType(id);
                if (feeType == null || feeType.FeeTypeId < 1)
                {
                    return(Json(new FeeTypeObject(), JsonRequestBehavior.AllowGet));
                }

                Session["_feeType"] = feeType;

                return(Json(feeType, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                return(Json(new FeeTypeObject(), JsonRequestBehavior.AllowGet));
            }
        }