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

            try
            {
                if (id < 1)
                {
                    gVal.Code  = -1;
                    gVal.Error = message_Feedback.Invalid_Selection;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                var k = new SubscriptionPackageServices().DeleteSubscriptionPackage(id);
                if (k)
                {
                    gVal.Code  = 5;
                    gVal.Error = message_Feedback.Delete_Success;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }
                gVal.Code  = -1;
                gVal.Error = message_Feedback.Delete_Failure;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
            catch
            {
                gVal.Code  = 5;
                gVal.Error = message_Feedback.Delete_Failure;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
        }
        public ActionResult GetSubscriptionPackageObjects(JQueryDataTableParamModel param)
        {
            try
            {
                IEnumerable <SubscriptionPackageObject> filteredSubscriptionPackageObjects;
                var countG = new SubscriptionPackageServices().GetObjectCount();

                var pagedSubscriptionPackageObjects = GetSubscriptionPackages(param.iDisplayLength, param.iDisplayStart);

                if (!string.IsNullOrEmpty(param.sSearch))
                {
                    filteredSubscriptionPackageObjects = new SubscriptionPackageServices().Search(param.sSearch);
                }
                else
                {
                    filteredSubscriptionPackageObjects = pagedSubscriptionPackageObjects;
                }

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

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

                //sortColumnIndex == 2 ? c.FileStorageSpace.ToString(CultureInfo.InvariantCulture) :
                //sortColumnIndex == 3 ? c.NumberOfStoreItems.ToString(CultureInfo.InvariantCulture) :
                //sortColumnIndex == 4 ? c.NumberOfOutlets.ToString(CultureInfo.InvariantCulture) :
                //sortColumnIndex == 5 ? c.Registers.ToString(CultureInfo.InvariantCulture) :
                //sortColumnIndex == 6 ? c.NumberOfUsers.ToString(CultureInfo.InvariantCulture) :
                //c.MaximumTransactions.ToString(CultureInfo.InvariantCulture)

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

                var displayedUserProfilenels = filteredSubscriptionPackageObjects;

                var result = from c in displayedUserProfilenels
                             select new[] { Convert.ToString(c.SubscriptionPackageId), c.PackageTitle, c.DedicatedAccountManager.ToString(CultureInfo.InvariantCulture), c.TelephoneSupport.ToString(CultureInfo.InvariantCulture),
                                            c.EmailSupport.ToString(CultureInfo.InvariantCulture), c.LiveChat.ToString(CultureInfo.InvariantCulture) };
                return(Json(new
                {
                    param.sEcho,
                    iTotalRecords = countG,
                    iTotalDisplayRecords = filteredSubscriptionPackageObjects.Count(),
                    aaData = result
                },
                            JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
                return(Json(new List <SubscriptionPackageObject>(), JsonRequestBehavior.AllowGet));
            }
        }
Example #3
0
        public ActionResult GetPackage(long id)
        {
            try
            {
                var package = new SubscriptionPackageServices().GetSubscriptionPackage(id);

                if (package == null || package.SubscriptionPackageId < 1)
                {
                    return(Json(new SubscriptionPackageObject(), JsonRequestBehavior.AllowGet));
                }
                return(Json(package, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                return(Json(new SubscriptionPackageObject(), JsonRequestBehavior.AllowGet));
            }
        }
        public ActionResult GetSubscriptionPackage(long id)
        {
            try
            {
                if (id < 1)
                {
                    return(Json(new SubscriptionPackageObject(), JsonRequestBehavior.AllowGet));
                }

                var subscriptionPackage = new SubscriptionPackageServices().GetSubscriptionPackage(id);
                if (id < 1)
                {
                    return(Json(new SubscriptionPackageObject(), JsonRequestBehavior.AllowGet));
                }
                Session["_subscriptionPackage"] = subscriptionPackage;
                return(Json(subscriptionPackage, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                return(Json(new SubscriptionPackageObject(), JsonRequestBehavior.AllowGet));
            }
        }
        public ActionResult AddSubscriptionPackage(SubscriptionPackageObject subscriptionPackage)
        {
            var gVal = new GenericValidator();

            try
            {
                //if (ModelState.IsValid)
                //{
                var valStatus = ValidateSubscriptionPackage(subscriptionPackage);
                if (valStatus.Code < 1)
                {
                    gVal.Code  = -1;
                    gVal.Error = valStatus.Error;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                var k = new SubscriptionPackageServices().AddSubscriptionPackage(subscriptionPackage);
                if (k < 1)
                {
                    gVal.Code  = -1;
                    gVal.Error = k == -3 ? message_Feedback.Item_Duplicate : message_Feedback.Update_Failure;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }
                gVal.Code = 5;
                return(Json(subscriptionPackage, JsonRequestBehavior.AllowGet));
                //}

                //gVal.Code = -1;
                //gVal.Error = message_Feedback.Model_State_Error;
                //return Json(gVal, JsonRequestBehavior.AllowGet);
            }
            catch
            {
                gVal.Code  = -1;
                gVal.Error = message_Feedback.Process_Failed;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
        }
        public ActionResult EditSubscriptionPackage(SubscriptionPackageObject subscriptionPackage)
        {
            var gVal = new GenericValidator();

            try
            {
                if (ModelState.IsValid)
                {
                    var valStatus = ValidateSubscriptionPackage(subscriptionPackage);
                    if (valStatus.Code < 1)
                    {
                        gVal.Code  = -1;
                        gVal.Error = valStatus.Error;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }

                    if (Session["_subscriptionPackage"] == null)
                    {
                        gVal.Code  = -1;
                        gVal.Error = message_Feedback.Session_Time_Out;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }

                    var oldSubscriptionPackage = Session["_subscriptionPackage"] as SubscriptionPackageObject;
                    if (oldSubscriptionPackage == null || oldSubscriptionPackage.SubscriptionPackageId < 1)
                    {
                        gVal.Code  = -1;
                        gVal.Error = message_Feedback.Session_Time_Out;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }
                    oldSubscriptionPackage.PackageTitle          = subscriptionPackage.PackageTitle.Trim();
                    oldSubscriptionPackage.FileStorageSpace      = subscriptionPackage.FileStorageSpace;
                    oldSubscriptionPackage.NumberOfStoreProducts = subscriptionPackage.NumberOfStoreProducts;
                    oldSubscriptionPackage.NumberOfOutlets       = subscriptionPackage.NumberOfOutlets;
                    oldSubscriptionPackage.Registers             = subscriptionPackage.Registers;
                    oldSubscriptionPackage.NumberOfUsers         = subscriptionPackage.NumberOfUsers;
                    oldSubscriptionPackage.UseReportBuilder      = subscriptionPackage.UseReportBuilder;
                    oldSubscriptionPackage.GenerateReports       = subscriptionPackage.GenerateReports;
                    oldSubscriptionPackage.MaximumTransactions   = subscriptionPackage.MaximumTransactions;
                    oldSubscriptionPackage.MaximumCustomer       = subscriptionPackage.MaximumCustomer;
                    oldSubscriptionPackage.TransactionFee        = subscriptionPackage.TransactionFee;
                    oldSubscriptionPackage.LiveChat                = subscriptionPackage.LiveChat;
                    oldSubscriptionPackage.EmailSupport            = subscriptionPackage.EmailSupport;
                    oldSubscriptionPackage.TelephoneSupport        = subscriptionPackage.TelephoneSupport;
                    oldSubscriptionPackage.DedicatedAccountManager = subscriptionPackage.DedicatedAccountManager;

                    if (!string.IsNullOrEmpty(subscriptionPackage.Note))
                    {
                        oldSubscriptionPackage.Note = subscriptionPackage.Note.Trim();
                    }

                    var k = new SubscriptionPackageServices().UpdateSubscriptionPackage(oldSubscriptionPackage);
                    if (k < 1)
                    {
                        gVal.Code  = -1;
                        gVal.Error = k == -3 ? message_Feedback.Item_Duplicate : message_Feedback.Update_Failure;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }
                    return(Json(oldSubscriptionPackage, JsonRequestBehavior.AllowGet));
                }

                gVal.Code  = -1;
                gVal.Error = message_Feedback.Model_State_Error;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
            catch
            {
                gVal.Code  = -1;
                gVal.Error = message_Feedback.Process_Failed;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
        }