示例#1
0
        public ActionResult GetStoreItemType(long id)
        {
            try
            {
                if (id < 1)
                {
                    return(Json(new StoreItemTypeObject(), JsonRequestBehavior.AllowGet));
                }

                var productType = new StoreItemTypeServices().GetStoreItemType(id);
                if (id < 1)
                {
                    return(Json(new StoreItemTypeObject(), JsonRequestBehavior.AllowGet));
                }
                Session["_productType"] = productType;
                if (!string.IsNullOrEmpty(productType.SampleImagePath))
                {
                    productType.SampleImagePath = productType.SampleImagePath.Replace("~", "");
                }
                return(Json(productType, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                return(Json(new StoreItemTypeObject(), JsonRequestBehavior.AllowGet));
            }
        }
示例#2
0
        public ActionResult DeleteStoreItemType(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 StoreItemTypeServices().DeleteStoreItemType(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));
            }
        }
示例#3
0
        public ActionResult GetStoreItemTypeObjects(JQueryDataTableParamModel param)
        {
            try
            {
                IEnumerable <StoreItemTypeObject> filteredStoreItemTypeObjects;
                var countG = new StoreItemTypeServices().GetObjectCount();

                var pagedStoreItemTypeObjects = GetStoreItemTypes(param.iDisplayLength, param.iDisplayStart);

                if (!string.IsNullOrEmpty(param.sSearch))
                {
                    filteredStoreItemTypeObjects = new StoreItemTypeServices().Search(param.sSearch);
                }
                else
                {
                    filteredStoreItemTypeObjects = pagedStoreItemTypeObjects;
                }

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

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

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

                var displayedUserProfilenels = filteredStoreItemTypeObjects;

                var result = from c in displayedUserProfilenels
                             select new[] { Convert.ToString(c.StoreItemTypeId), c.Name };
                return(Json(new
                {
                    param.sEcho,
                    iTotalRecords = countG,
                    iTotalDisplayRecords = filteredStoreItemTypeObjects.Count(),
                    aaData = result
                },
                            JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
                return(Json(new List <StoreItemTypeObject>(), JsonRequestBehavior.AllowGet));
            }
        }
示例#4
0
        public ActionResult AddStoreItemType(StoreItemTypeObject productType)
        {
            var gVal = new GenericValidator();

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

                    var logoPath = SaveFile("");
                    if (!string.IsNullOrEmpty(logoPath))
                    {
                        productType.SampleImagePath = logoPath;
                    }
                    var k = new StoreItemTypeServices().AddStoreItemType(productType);
                    if (k < 1)
                    {
                        if (k == -3)
                        {
                            productType.Name = message_Feedback.Item_Duplicate;
                        }

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

                    gVal.Code  = k;
                    gVal.Error = message_Feedback.Insertion_Success;
                    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));
            }
        }
示例#5
0
        public ActionResult EditStoreItemType(StoreItemTypeObject productType)
        {
            var gVal = new GenericValidator();

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

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

                    var oldStoreItemType = Session["_productType"] as StoreItemTypeObject;
                    if (oldStoreItemType == null || oldStoreItemType.StoreItemTypeId < 1)
                    {
                        gVal.Code  = -5;
                        gVal.Error = message_Feedback.Session_Time_Out;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }

                    oldStoreItemType.Name = productType.Name.Trim();

                    if (!string.IsNullOrEmpty(productType.Description))
                    {
                        oldStoreItemType.Description = productType.Description.Trim();
                    }

                    var formerSampleImagePath = string.Empty;
                    if (!string.IsNullOrEmpty(oldStoreItemType.SampleImagePath))
                    {
                        formerSampleImagePath = oldStoreItemType.SampleImagePath;
                    }

                    var logoPath = SaveFile(formerSampleImagePath);

                    if (!string.IsNullOrEmpty(logoPath))
                    {
                        oldStoreItemType.SampleImagePath = logoPath;
                    }

                    var k = new StoreItemTypeServices().UpdateStoreItemType(oldStoreItemType);
                    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;
                    gVal.Error = message_Feedback.Update_Success;
                    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));
            }
        }