Пример #1
0
        public ActionResult DeleteAccountGroup(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 AccountGroupServices().DeleteAccountGroup(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.Process_Failed;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
        }
Пример #2
0
        public ActionResult EditAccountGroup(AccountGroupObject accountGroup)
        {
            var gVal = new GenericValidator();

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

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

                    var oldAccountGroup = Session["_accountGroup"] as AccountGroupObject;
                    if (oldAccountGroup == null || oldAccountGroup.AccountGroupId < 1)
                    {
                        gVal.Code  = -1;
                        gVal.Error = message_Feedback.Session_Time_Out;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }
                    oldAccountGroup.Name = accountGroup.Name.Trim();

                    var k = new AccountGroupServices().UpdateAccountGroup(oldAccountGroup);
                    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;
                    gVal.Error = message_Feedback.Update_Success;
                    return(Json(gVal, 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));
            }
        }
Пример #3
0
        public ActionResult GetAccountGroups(string subdomain)
        {
            var storeSetting = new SessionHelpers().GetStoreInfo(subdomain);

            if (storeSetting == null || storeSetting.StoreId < 1)
            {
                return(RedirectToAction("Index", "Home"));
            }
            var countries = new AccountGroupServices().GetAccountGroups() ?? new List <AccountGroupObject>();

            return(Json(countries, JsonRequestBehavior.AllowGet));
        }
Пример #4
0
        public ActionResult GetAccountGroupObjects(JQueryDataTableParamModel param)
        {
            try
            {
                IEnumerable <AccountGroupObject> filteredAccountGroupObjects;
                var countG = new AccountGroupServices().GetObjectCount();

                var pagedAccountGroupObjects = GetAccountGroups(param.iDisplayLength, param.iDisplayStart);

                if (!string.IsNullOrEmpty(param.sSearch))
                {
                    filteredAccountGroupObjects = new AccountGroupServices().Search(param.sSearch);
                }
                else
                {
                    filteredAccountGroupObjects = pagedAccountGroupObjects;
                }

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

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

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

                var displayedUserProfilenels = filteredAccountGroupObjects;

                var result = from c in displayedUserProfilenels
                             select new[] { Convert.ToString(c.AccountGroupId), c.Name };
                return(Json(new
                {
                    param.sEcho,
                    iTotalRecords = countG,
                    iTotalDisplayRecords = filteredAccountGroupObjects.Count(),
                    aaData = result
                },
                            JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
                return(Json(new List <AccountGroupObject>(), JsonRequestBehavior.AllowGet));
            }
        }
Пример #5
0
        public ActionResult AddAccountGroup(AccountGroupObject accountGroup)
        {
            var gVal = new GenericValidator();

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

                    var k = new AccountGroupServices().AddAccountGroup(accountGroup);
                    if (k < 1)
                    {
                        gVal.Code  = -1;
                        gVal.Error = k == -3 ? message_Feedback.Item_Duplicate : message_Feedback.Insertion_Failure;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }
                    gVal.Code  = 5;
                    gVal.Error = message_Feedback.Insertion_Success;
                    return(Json(gVal, 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));
            }
        }
Пример #6
0
        public ActionResult GetAccountGroup(long id)
        {
            try
            {
                if (id < 1)
                {
                    return(Json(new AccountGroupObject(), JsonRequestBehavior.AllowGet));
                }

                var accountGroup = new AccountGroupServices().GetAccountGroup(id);
                if (id < 1)
                {
                    return(Json(new AccountGroupObject(), JsonRequestBehavior.AllowGet));
                }
                Session["_accountGroup"] = accountGroup;
                return(Json(accountGroup, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                return(Json(new AccountGroupObject(), JsonRequestBehavior.AllowGet));
            }
        }