Exemple #1
0
        public ActionResult GetStoreItemCategory(long id)
        {
            try
            {
                if (id < 1)
                {
                    return(Json(new StoreItemCategoryObject(), JsonRequestBehavior.AllowGet));
                }

                var storeItemCategory = new StoreItemCategoryServices().GetStoreItemCategory(id);
                if (id < 1)
                {
                    return(Json(new StoreItemCategoryObject(), JsonRequestBehavior.AllowGet));
                }
                Session["_storeItemCategory"] = storeItemCategory;
                if (!string.IsNullOrEmpty(storeItemCategory.ImagePath))
                {
                    storeItemCategory.ImagePath = storeItemCategory.ImagePath.Replace("~", "");
                }
                return(Json(storeItemCategory, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                return(Json(new StoreItemCategoryObject(), JsonRequestBehavior.AllowGet));
            }
        }
Exemple #2
0
        public ActionResult DeleteStoreItemCategory(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 StoreItemCategoryServices().DeleteStoreItemCategory(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));
            }
        }
Exemple #3
0
        public ActionResult GetStoreItemCategoryObjects(JQueryDataTableParamModel param)
        {
            try
            {
                IEnumerable <StoreItemCategoryObject> filteredStoreItemCategoryObjects;
                var countG = new StoreItemCategoryServices().GetObjectCount();

                var pagedStoreItemCategoryObjects = GetStoreItemCategorys(param.iDisplayLength, param.iDisplayStart);

                if (!string.IsNullOrEmpty(param.sSearch))
                {
                    filteredStoreItemCategoryObjects = new StoreItemCategoryServices().Search(param.sSearch);
                }
                else
                {
                    filteredStoreItemCategoryObjects = pagedStoreItemCategoryObjects;
                }

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

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

                var sortDirection = Request["sSortDir_0"]; // asc or desc
                if (sortDirection == "asc")
                {
                    filteredStoreItemCategoryObjects = filteredStoreItemCategoryObjects.OrderBy(orderingFunction);
                }
                else
                {
                    filteredStoreItemCategoryObjects = filteredStoreItemCategoryObjects.OrderByDescending(orderingFunction);
                }

                var displayedUserProfilenels = filteredStoreItemCategoryObjects;

                var result = from c in displayedUserProfilenels
                             select new[] { Convert.ToString(c.StoreItemCategoryId), c.Name, c.ParentName };
                return(Json(new
                {
                    param.sEcho,
                    iTotalRecords = countG,
                    iTotalDisplayRecords = filteredStoreItemCategoryObjects.Count(),
                    aaData = result
                },
                            JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
                return(Json(new List <StoreItemCategoryObject>(), JsonRequestBehavior.AllowGet));
            }
        }
Exemple #4
0
        public ActionResult AddStoreItemCategory(StoreItemCategoryObject storeItemCategory)
        {
            var gVal = new GenericValidator();

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

                    var logoPath = SaveFile("");
                    if (!string.IsNullOrEmpty(logoPath))
                    {
                        storeItemCategory.ImagePath = logoPath;
                    }

                    storeItemCategory.LastUpdated = DateTime.Now;

                    var k = new StoreItemCategoryServices().AddStoreItemCategory(storeItemCategory);
                    if (k < 1)
                    {
                        if (k == -3)
                        {
                            gVal.Error = message_Feedback.Item_Duplicate;
                        }

                        if (k != -3 && k != -4)
                        {
                            gVal.Error = message_Feedback.Insertion_Failure;
                        }
                        gVal.Code = -1;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }

                    gVal.Code = 5;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                gVal.Code  = -5;
                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));
            }
        }
Exemple #5
0
        public ActionResult GetStoreItemCategories()
        {
            var itemCategories = new StoreItemCategoryServices().GetStoreItemCategories() ?? new List <StoreItemCategoryObject>();

            return(Json(itemCategories, JsonRequestBehavior.AllowGet));
        }
Exemple #6
0
        public ActionResult EditStoreItemCategory(StoreItemCategoryObject storeItemCategory)
        {
            var gVal = new GenericValidator();

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

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

                    var oldStoreItemCategory = Session["_storeItemCategory"] as StoreItemCategoryObject;
                    if (oldStoreItemCategory == null || oldStoreItemCategory.StoreItemCategoryId < 1)
                    {
                        gVal.Code  = -1;
                        gVal.Error = message_Feedback.Session_Time_Out;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }

                    oldStoreItemCategory.Name = storeItemCategory.Name.Trim();

                    if (!string.IsNullOrEmpty(storeItemCategory.Description))
                    {
                        oldStoreItemCategory.Description = storeItemCategory.Description.Trim();
                    }

                    if (storeItemCategory.ParentCategoryId > 0)
                    {
                        oldStoreItemCategory.ParentCategoryId = storeItemCategory.ParentCategoryId;
                    }

                    var formerImagePath = string.Empty;
                    if (!string.IsNullOrEmpty(oldStoreItemCategory.ImagePath))
                    {
                        formerImagePath = oldStoreItemCategory.ImagePath;
                    }

                    var logoPath = SaveFile(formerImagePath);

                    if (!string.IsNullOrEmpty(logoPath))
                    {
                        oldStoreItemCategory.ImagePath = logoPath;
                    }
                    oldStoreItemCategory.LastUpdated = DateTime.Now;
                    var k = new StoreItemCategoryServices().UpdateStoreItemCategory(oldStoreItemCategory);
                    if (k < 1)
                    {
                        if (k == -3)
                        {
                            gVal.Error = message_Feedback.Item_Duplicate;
                        }

                        if (k != -3 && k != -4)
                        {
                            gVal.Error = message_Feedback.Update_Failure;
                        }
                        gVal.Code = -1;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }
                    gVal.Code = 5;
                    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));
            }
        }