Exemple #1
0
        public List <CategoriesModels> GetListCategoryInte(string StoreID = null, string CategoryId = null, string ProductTypeID = null, List <string> ListOrganizationId = null)
        {
            List <CategoriesModels> listData = new List <CategoriesModels>();

            try
            {
                CategoriesApiModels paraBody = new CategoriesApiModels();
                paraBody.AppKey      = Commons.AppKey;
                paraBody.AppSecret   = Commons.AppSecret;
                paraBody.CreatedUser = Commons.CreateUser;

                paraBody.ProductTypeID = ProductTypeID;
                paraBody.StoreID       = StoreID;
                paraBody.ID            = CategoryId;

                paraBody.isGetChild = true;
                paraBody.ListOrgID  = ListOrganizationId;

                var     result     = (ResponseApiModels)ApiResponse.Post <ResponseApiModels>(Commons.GetCategories, null, paraBody);
                dynamic data       = result.Data;
                var     lstC       = data["ListCategory"];
                var     lstContent = JsonConvert.SerializeObject(lstC /*result.RawData*/);
                listData = JsonConvert.DeserializeObject <List <CategoriesModels> >(lstContent);
                return(listData);
            }
            catch (Exception e)
            {
                _logger.Error("Categories_GetList: " + e);
                return(listData);
            }
        }
Exemple #2
0
        // Updated 09082017
        public List <SBInventoryBaseCateGroupViewModel> GetListCategorySortParentForEditCate(string StoreID = null, string CategoryId = null, string ProductTypeID = null, List <string> ListOrganizationId = null, string cateID = "0", string parentID = "0")
        {
            List <CategoriesModels> listData = new List <CategoriesModels>();
            List <SBInventoryBaseCateGroupViewModel> lstCateGroup = new List <SBInventoryBaseCateGroupViewModel>();

            try
            {
                CategoriesApiModels paraBody = new CategoriesApiModels();
                paraBody.AppKey      = Commons.AppKey;
                paraBody.AppSecret   = Commons.AppSecret;
                paraBody.CreatedUser = Commons.CreateUser;

                paraBody.ProductTypeID = ProductTypeID;
                paraBody.StoreID       = StoreID;
                paraBody.ID            = CategoryId;

                paraBody.isGetChild = true;
                paraBody.ListOrgID  = ListOrganizationId;

                var     result     = (ResponseApiModels)ApiResponse.Post <ResponseApiModels>(Commons.GetCategories, null, paraBody);
                dynamic data       = result.Data;
                var     lstC       = data["ListCategory"];
                var     lstContent = JsonConvert.SerializeObject(lstC /*result.RawData*/);
                listData = JsonConvert.DeserializeObject <List <CategoriesModels> >(lstContent);
                var currentUser = (UserSession)System.Web.HttpContext.Current.Session["User"];
                if (currentUser != null)
                {
                    listData = listData.Where(ww => currentUser.ListStoreID.Contains(ww.StoreID)).ToList();
                }

                // Sort by Sequence, Name
                List <CategoriesModels> parentItems = listData.Where(w => string.IsNullOrEmpty(w.ParentID) && !w.ID.Equals(cateID)).OrderBy(o => o.Sequence).ThenBy(o => o.Name).ToList();
                int levelCate = 0;
                foreach (var parentCat in parentItems)
                {
                    lstCateGroup.Add(new SBInventoryBaseCateGroupViewModel
                    {
                        Id       = parentCat.ID,
                        Name     = parentCat.Name,
                        Level    = "level" + levelCate,
                        Selected = parentCat.ID.Equals(parentID) ? true : false
                    });

                    // No include cate child of current cate
                    List <CategoriesModels> childItems = listData.Where(w => !string.IsNullOrEmpty(w.ParentID) && w.ParentID == parentCat.ID && !w.ID.Equals(cateID)).OrderBy(o => o.Sequence).ThenBy(o => o.Name).ToList();
                    if (childItems.Count > 0)
                    {
                        AddChildCateForEditCate(ref lstCateGroup, cateID, listData, childItems, levelCate, parentID);
                    }
                }

                return(lstCateGroup);
            }
            catch (Exception e)
            {
                _logger.Error("Categories_GetList: " + e);
                return(lstCateGroup);
            }
        }
Exemple #3
0
        public bool InsertOrUpdateCategories(CategoriesModels model, ref string msg)
        {
            try
            {
                CategoriesApiModels paraBody = new CategoriesApiModels();
                paraBody.AppKey        = Commons.AppKey;
                paraBody.AppSecret     = Commons.AppSecret;
                paraBody.CreatedUser   = Commons.CreateUser;
                paraBody.RegisterToken = new RegisterTokenModels();

                paraBody.ID      = model.ID;
                paraBody.StoreID = model.StoreID;

                paraBody.Name                = model.Name;
                paraBody.Sequence            = model.Sequence;
                paraBody.Description         = model.Description;
                paraBody.TotalProducts       = model.TotalProducts;
                paraBody.ImageURL            = model.ImageURL;
                paraBody.ParentID            = model.ParentID;
                paraBody.ProductTypeID       = model.ProductTypeID;
                paraBody.Type                = model.Type;
                paraBody.IsShowInReservation = model.IsShowInReservation;
                paraBody.IsShowInKiosk       = model.IsShowInKiosk;
                paraBody.IsGiftCard          = model.IsGiftCard;
                paraBody.IsIncludeNetSale    = model.IsIncludeNetSale;
                paraBody.GLAccountCode       = model.GLAccountCode;

                //====================
                NSLog.Logger.Info("InsertOrUpdateCategories Request", paraBody);
                var result = (ResponseApiModels)ApiResponse.Post <ResponseApiModels>(Commons.CreateOrEditCategories, null, paraBody);
                NSLog.Logger.Info("InsertOrUpdateCategories Result", result);
                if (result != null)
                {
                    if (result.Success)
                    {
                        return(true);
                    }
                    else
                    {
                        msg = result.Message;
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception e)
            {
                NSLog.Logger.Error("InsertOrUpdateCategories Error", e);
                return(false);
            }
        }
Exemple #4
0
        public bool DeleteCategories(string ID, ref string msg)
        {
            try
            {
                CategoriesApiModels paraBody = new CategoriesApiModels();
                paraBody.AppKey        = Commons.AppKey;
                paraBody.AppSecret     = Commons.AppSecret;
                paraBody.CreatedUser   = Commons.CreateUser;
                paraBody.RegisterToken = new RegisterTokenModels();

                paraBody.ID = ID;

                NSLog.Logger.Info("DeleteCategories Request", paraBody);
                //====================
                var result = (ResponseApiModels)ApiResponse.Post <ResponseApiModels>(Commons.DeleteCategories, null, paraBody);
                NSLog.Logger.Info("DeleteCategories Result", result);
                if (result != null)
                {
                    if (result.Success)
                    {
                        return(true);
                    }
                    else
                    {
                        msg = result.Message;

                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception e)
            {
                msg = e.ToString();
                NSLog.Logger.Error("DeleteCategories Error", e);
                return(false);
            }
        }
Exemple #5
0
        public List <CategoriesModels> GetListCategory(string StoreID = null, string CategoryId = null, string ProductTypeID = null, List <string> ListOrganizationId = null)
        {
            List <CategoriesModels> listData = new List <CategoriesModels>();

            try
            {
                CategoriesApiModels paraBody = new CategoriesApiModels();
                paraBody.AppKey      = Commons.AppKey;
                paraBody.AppSecret   = Commons.AppSecret;
                paraBody.CreatedUser = Commons.CreateUser;

                paraBody.ProductTypeID = ProductTypeID;
                paraBody.StoreID       = StoreID;
                paraBody.ID            = CategoryId;

                paraBody.isGetChild = true;
                paraBody.ListOrgID  = ListOrganizationId;
                NSLog.Logger.Info("GetListCategory Request", paraBody);

                var result = (ResponseApiModels)ApiResponse.Post <ResponseApiModels>(Commons.GetCategories, null, paraBody);
                NSLog.Logger.Info("GetListCategory Result", paraBody);
                dynamic data       = result.Data;
                var     lstC       = data["ListCategory"];
                var     lstContent = JsonConvert.SerializeObject(lstC /*result.RawData*/);
                listData = JsonConvert.DeserializeObject <List <CategoriesModels> >(lstContent);
                var currentUser = (UserSession)System.Web.HttpContext.Current.Session["User"];
                if (currentUser != null)
                {
                    listData = listData.Where(ww => currentUser.ListStoreID.Contains(ww.StoreID)).ToList();
                }
                return(listData);
            }
            catch (Exception e)
            {
                NSLog.Logger.Error("GetListCategory Error", e);
                return(listData);
            }
        }