Esempio n. 1
0
        public ActionResult DeleteStoreItem(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 StoreItemServices().DeleteStoreItem(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));
            }
        }
Esempio n. 2
0
        public ActionResult GetStoreItem(long id)
        {
            try
            {
                if (id < 1)
                {
                    return(Json(new StoreItemObject(), JsonRequestBehavior.AllowGet));
                }

                var product = new StoreItemServices().GetStoreItem(id);
                if (id < 1)
                {
                    return(Json(new StoreItemObject(), JsonRequestBehavior.AllowGet));
                }
                Session["_product"] = product;
                //if (!string.IsNullOrEmpty(product.SampleImagePath))
                //{
                //    product.SampleImagePath = product.SampleImagePath.Replace("~", "");
                //}
                return(Json(product, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                return(Json(new StoreItemObject(), JsonRequestBehavior.AllowGet));
            }
        }
Esempio n. 3
0
        public ActionResult AddStoreItem(StoreItemObject product)
        {
            var gVal = new GenericValidator();

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

                    //var logoPath = SaveFile("");
                    //if (!string.IsNullOrEmpty(logoPath))
                    //{
                    //    product.SampleImagePath = logoPath;
                    //}
                    var k = new StoreItemServices().AddStoreItem(product);
                    if (k < 1)
                    {
                        if (k == -3)
                        {
                            product.Name = message_Feedback.Item_Duplicate;
                        }
                        if (k == -4)
                        {
                            product.Name = message_Feedback.Insertion_Failure;
                        }
                        if (k != -3 && k != -4)
                        {
                            product.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));
            }
        }
Esempio n. 4
0
        public ActionResult GetStoreItemObjects(JQueryDataTableParamModel param)
        {
            try
            {
                IEnumerable <StoreItemObject> filteredStoreItemObjects;
                var countG = new StoreItemServices().GetObjectCount();

                var pagedStoreItemObjects = GetStoreItems(param.iDisplayLength, param.iDisplayStart);

                if (!string.IsNullOrEmpty(param.sSearch))
                {
                    filteredStoreItemObjects = new StoreItemServices().Search(param.sSearch);
                }
                else
                {
                    filteredStoreItemObjects = pagedStoreItemObjects;
                }

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

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

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

                var displayedUserProfilenels = filteredStoreItemObjects;

                var result = from c in displayedUserProfilenels
                             select new[] { Convert.ToString(c.StoreItemId), c.Name, c.StoreItemCategoryName, c.StoreItemTypeName, c.StoreItemBrandName, c.ParentItemName, c.ChartOfAccountTypeName };
                return(Json(new
                {
                    param.sEcho,
                    iTotalRecords = countG,
                    iTotalDisplayRecords = filteredStoreItemObjects.Count(),
                    aaData = result
                },
                            JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
                return(Json(new List <StoreItemObject>(), JsonRequestBehavior.AllowGet));
            }
        }
Esempio n. 5
0
        public ActionResult EditStoreItem(StoreItemObject product)
        {
            var gVal = new GenericValidator();

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

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

                    var oldStoreItem = Session["_product"] as StoreItemObject;
                    if (oldStoreItem == null || oldStoreItem.StoreItemId < 1)
                    {
                        gVal.Code  = -5;
                        gVal.Error = message_Feedback.Session_Time_Out;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }

                    oldStoreItem.Name                = product.Name.Trim();
                    oldStoreItem.ChartOfAccountId    = product.ChartOfAccountId;
                    oldStoreItem.StoreItemBrandId    = product.StoreItemBrandId;
                    oldStoreItem.StoreItemTypeId     = product.StoreItemTypeId;
                    oldStoreItem.StoreItemCategoryId = product.StoreItemCategoryId;

                    if (product.ParentItemId > 0)
                    {
                        oldStoreItem.ParentItemId = product.ParentItemId;
                    }

                    if (!string.IsNullOrEmpty(product.Description))
                    {
                        oldStoreItem.Description = product.Description.Trim();
                    }

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

                    //var logoPath = SaveFile(formerSampleImagePath);

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

                    var k = new StoreItemServices().UpdateStoreItem(oldStoreItem);
                    if (k < 1)
                    {
                        gVal.Error = k == -3 ? message_Feedback.Item_Duplicate : 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));
            }
        }