Ejemplo n.º 1
0
 public ActionResult New()
 {
     string user_id = HttpContext.User.Identity.Name;
     UserManager userMgr = new UserManager(int.Parse(user_id), null);
     BUser user = userMgr.CurrentUser;
     Shop MainShop = userMgr.Main_Shop;
     ShopCategoryManager cateMgr = new ShopCategoryManager(userMgr.CurrentUser, MainShop, userMgr.CurrentUserPermission);
     List<BCategory> categories = cateMgr.GetCategories(0);
     ViewData["category"] = categories;
     return View();
 }
Ejemplo n.º 2
0
        public ApiMessage AddNewPropValue()
        {
            ApiMessage message = new ApiMessage();
            string user_id = User.Identity.Name;
            UserManager userMgr = new UserManager(int.Parse(user_id), null);
            BUser user = userMgr.CurrentUser;
            Shop MainShop = userMgr.Main_Shop;
            ShopCategoryManager cateMgr = new ShopCategoryManager(userMgr.CurrentUser, MainShop, userMgr.CurrentUserPermission);
            HttpContextBase context = (HttpContextBase)Request.Properties["MS_HttpContext"];
            HttpRequestBase request = context.Request;
            string propId = request["prop_id"];
            string propValues = request["prop_values"];
            if (!string.IsNullOrEmpty(propValues))
            {
                string[] values = propValues.Split(',');
                List<string> vs = new List<string>();

                if (values != null && values.Length > 0)
                {
                    for (int i = 0; i < values.Length; i++)
                    {
                        vs.Add(values[i]);
                    }
                }

                try
                {
                    if (cateMgr.AddNewPropValue(int.Parse(propId), vs))
                    {
                        message.Status = "ok";
                    }
                    else
                    {
                        message.Status = "failed";
                    }
                }
                catch (KM.JXC.Common.KMException.KMJXCException ex)
                {
                    message.Status = "failed";
                    message.Message = ex.Message;
                }
            }
            return message;
        }
Ejemplo n.º 3
0
        public ApiMessage Add()
        {
            string user_id = User.Identity.Name;
            UserManager userMgr = new UserManager(int.Parse(user_id), null);
            BUser user = userMgr.CurrentUser;
            Shop cShop = userMgr.Shop;
            ShopCategoryManager cateMgr = new ShopCategoryManager(userMgr.CurrentUser, cShop, userMgr.CurrentUserPermission);

            HttpContextBase context = (HttpContextBase)Request.Properties["MS_HttpContext"];
            HttpRequestBase request = context.Request;
            ApiMessage message = new ApiMessage();
            try
            {
                BCategory cate = new BCategory();
                cate.Name = request["name"].ToString();
                cate.ID = 0;
                cate.Mall_ID = "";
                cate.Mall_PID = "";
                cate.Created = DateTimeUtil.ConvertDateTimeToInt(DateTime.Now);
                cate.Parent = new BCategory() { ID = int.Parse(request["parent_id"].ToString()) };
                cateMgr.CreateCategory(cate);
                message.Status = "ok";
                message.Message = "分类创建成功";
                message.Item = cate;
            }
            catch (KM.JXC.Common.KMException.KMJXCException ex)
            {
                message.Status = "failed";
                message.Message = ex.Message;
            }
            catch (Exception ex)
            {
                message.Status = "failed";
                message.Message = "分类创建失败";
            }

            return message;
        }
Ejemplo n.º 4
0
 public PQGridData GetPropertyValues()
 {
     string user_id = User.Identity.Name;
     UserManager userMgr = new UserManager(int.Parse(user_id), null);
     PQGridData data = new PQGridData();
     BUser user = userMgr.CurrentUser;
     ShopCategoryManager cateMgr = new ShopCategoryManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission);
     int property_id = 0;
     HttpContextBase context = (HttpContextBase)Request.Properties["MS_HttpContext"];
     HttpRequestBase request = context.Request;
     int.TryParse(request["pid"], out property_id);
     data.data = cateMgr.GetPropertyValues(property_id);
     return data;
 }
Ejemplo n.º 5
0
        public BProperty GetProperty()
        {
            BProperty property = new BProperty();
            string user_id = User.Identity.Name;
            UserManager userMgr = new UserManager(int.Parse(user_id), null);
            BUser user = userMgr.CurrentUser;
            Shop MainShop = userMgr.Main_Shop;
            ShopCategoryManager cateMgr = new ShopCategoryManager(userMgr.CurrentUser, MainShop, userMgr.CurrentUserPermission);
            HttpContextBase context = (HttpContextBase)Request.Properties["MS_HttpContext"];
            HttpRequestBase request = context.Request;
            int propId = 0;
            int.TryParse(request["prop_id"],out propId);
            List<BProperty> properties = cateMgr.GetProperties(0,propId);
            if (properties.Count == 1)
            {
                property = properties[0];
            }

            return property;
        }
Ejemplo n.º 6
0
 public PQGridData GetPropertiesT()
 {
     string user_id = User.Identity.Name;
     UserManager userMgr = new UserManager(int.Parse(user_id), null);
     ApiMessage message = new ApiMessage();
     BUser user = userMgr.CurrentUser;
     ShopCategoryManager cateMgr = new ShopCategoryManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission);
     int categoryId = 0;
     HttpContextBase context = (HttpContextBase)Request.Properties["MS_HttpContext"];
     HttpRequestBase request = context.Request;
     int.TryParse(request["cid"], out categoryId);
     string sortBy = "";
     string dir = "";
     if (request["sortBy"] != null)
     {
         sortBy = request["sortBy"];
     }
     if (request["dir"] != null)
     {
         sortBy = request["dir"];
     }
     List<BProperty> properties = cateMgr.GetProperties(categoryId,0,sortBy,dir);
     PQGridData grid = new PQGridData();
     grid.curPage = 1;
     grid.totalRecords = properties.Count;
     grid.data = properties;
     message.Item = grid;
     message.Status="ok";
     return grid;
 }
Ejemplo n.º 7
0
 public List<BProperty> GetProperties(int categoryId)
 {
     string user_id = User.Identity.Name;
     UserManager userMgr = new UserManager(int.Parse(user_id), null);
     BUser user = userMgr.CurrentUser;
     Shop MainShop = userMgr.Main_Shop;
     ShopCategoryManager cateMgr = new ShopCategoryManager(userMgr.CurrentUser, MainShop, userMgr.CurrentUserPermission);
     List<BProperty> properties = cateMgr.GetProperties(categoryId);
     return properties;
 }
Ejemplo n.º 8
0
 public IEnumerable<BCategory> GetOnlineCategories()
 {
     string user_id = User.Identity.Name;
     UserManager userMgr = new UserManager(int.Parse(user_id), null);
     BUser user = userMgr.CurrentUser;
     Shop MainShop = userMgr.Main_Shop;
     ShopCategoryManager cateMgr = new ShopCategoryManager(userMgr.CurrentUser, MainShop, userMgr.CurrentUserPermission);
     List<BCategory> cates = cateMgr.GetOnlineCategories();
     List<BProperty> props = cateMgr.GetOnlineProperties();
     return cates;
 }
Ejemplo n.º 9
0
        public PQGridData GetCategories()
        {
            PQGridData data = new PQGridData();
            string user_id = User.Identity.Name;
            UserManager userMgr = new UserManager(int.Parse(user_id), null);
            BUser user = userMgr.CurrentUser;
            Shop MainShop = userMgr.Main_Shop;
            ShopCategoryManager cateMgr = new ShopCategoryManager(userMgr.CurrentUser, MainShop, userMgr.CurrentUserPermission);

            HttpContextBase context = (HttpContextBase)Request.Properties["MS_HttpContext"];
            HttpRequestBase request = context.Request;
            int id = 0;
            if (!string.IsNullOrEmpty(request["parent_id"]))
            {
                id = int.Parse(request["parent_id"].ToString());
            }

            List<BCategory> categories = new List<BCategory>();
            categories = cateMgr.GetCategories(id);
            data.curPage = 1;
            data.totalRecords = categories.Count;
            data.data = categories;
            return data;
        }
Ejemplo n.º 10
0
        public BCategory Get(int id)
        {
            string user_id = User.Identity.Name;
            UserManager userMgr = new UserManager(int.Parse(user_id), null);
            BUser user = userMgr.CurrentUser;
            Shop MainShop = userMgr.Main_Shop;
            ShopCategoryManager cateMgr = new ShopCategoryManager(userMgr.CurrentUser, MainShop, userMgr.CurrentUserPermission);
            BCategory cate = cateMgr.GetCategory(id);

            return cate;
        }
Ejemplo n.º 11
0
        public ApiMessage DisableCategory()
        {
            ApiMessage message = new ApiMessage() { Status = "failed", Message = "" };
            string user_id = User.Identity.Name;
            UserManager userMgr = new UserManager(int.Parse(user_id), null);
            BUser user = userMgr.CurrentUser;
            Shop MainShop = userMgr.Main_Shop;
            ShopCategoryManager cateMgr = new ShopCategoryManager(userMgr.CurrentUser, MainShop, userMgr.CurrentUserPermission);

            HttpContextBase context = (HttpContextBase)Request.Properties["MS_HttpContext"];
            HttpRequestBase request = context.Request;
            int category_id = 0;
            int.TryParse(request["cid"],out category_id);
            try
            {
                if (cateMgr.DisableCategory(category_id))
                {
                    message.Status = "ok";
                }
                else
                {
                    message.Message = "操作失败";
                }
            }
            catch (KM.JXC.Common.KMException.KMJXCException kex)
            {
                message.Message = kex.Message;
            }
            catch (Exception ex)
            {

            }
            return message;
        }
Ejemplo n.º 12
0
        public ApiMessage CreateProperty()
        {
            BProperty property = new BProperty();
            ApiMessage message = new ApiMessage();
            string user_id = User.Identity.Name;
            UserManager userMgr = new UserManager(int.Parse(user_id), null);
            BUser user = userMgr.CurrentUser;
            Shop currentShop = userMgr.Shop;
            ShopCategoryManager cateMgr = new ShopCategoryManager(userMgr.CurrentUser, currentShop, userMgr.CurrentUserPermission);
            HttpContextBase context = (HttpContextBase)Request.Properties["MS_HttpContext"];
            HttpRequestBase request = context.Request;
            string categoryId = request["category_id"];
            string propName = request["prop_name"];
            string propValue = request["prop_value"];
            List<string> propValues = new List<string>();
            if (!string.IsNullOrEmpty(propValue))
            {
                string[] vs = propValue.Split(',');
                if (vs != null && vs.Length > 0)
                {
                    for (int i = 0; i < vs.Length; i++)
                    {
                        propValues.Add(vs[i]);
                    }
                }
            }

            try
            {
                property = cateMgr.CreateProperty(int.Parse(categoryId), propName, propValues);
                message.Item = property;
                message.Status = "ok";
            }
            catch (KM.JXC.Common.KMException.KMJXCException ex)
            {
                message.Status = "failed";
                message.Message = ex.Message;
                message.Item = null;
            }
            catch (Exception nex)
            {

            }

            return message;
        }
Ejemplo n.º 13
0
        public ApiMessage BatchUpdatePropertiesCategory()
        {
            ApiMessage message = new ApiMessage() { Status = "ok", Message = "" };
            string user_id = User.Identity.Name;
            UserManager userMgr = new UserManager(int.Parse(user_id), null);
            BUser user = userMgr.CurrentUser;
            Shop MainShop = userMgr.Main_Shop;
            ShopCategoryManager cateMgr = new ShopCategoryManager(userMgr.CurrentUser, MainShop, userMgr.CurrentUserPermission);

            HttpContextBase context = (HttpContextBase)Request.Properties["MS_HttpContext"];
            HttpRequestBase request = context.Request;
            int[] props = null;
            int category_id = 0;
            try
            {
                int.TryParse(request["category_id"],out category_id);
                props = base.ConvertToIntArrar(request["props"]);
                cateMgr.BatchUpdatePropertiesCategory(props, category_id);
            }
            catch (KM.JXC.Common.KMException.KMJXCException kex)
            {
                message.Message = kex.Message;
            }
            catch (Exception ex)
            {

            }
            return message;
        }
Ejemplo n.º 14
0
 public ActionResult NewCategory()
 {
     string user_id = HttpContext.User.Identity.Name;
     UserManager userMgr = new UserManager(int.Parse(user_id), null);
     BUser user = userMgr.CurrentUser;
     Shop MainShop = userMgr.Main_Shop;
     ShopCategoryManager cateMgr = new ShopCategoryManager(userMgr.CurrentUser, MainShop, userMgr.CurrentUserPermission);
     List<BCategory> categories = cateMgr.GetCategories(0);
     return View((from cate in categories where cate.Parent==null || cate.Parent.ID == 0 select cate).ToList<BCategory>());
 }