示例#1
0
        /// <summary>
        /// 获取所有的商品分类
        /// </summary>
        /// <returns></returns>
        protected string GetAllItemCategories()
        {
            var bll  = new ItemCategoryService(this.CurrentUserInfo);
            var list = bll.GetItemCagegoryList("", "");

            return(list.ToJSON());
        }
示例#2
0
 public async Task <JsonResult> GetByID(string id)
 {
     try {
         var data = ItemCategoryService.GetByID(Guid.Parse(id));
         return(Success(ItemCategoryVM.MToVM(data)));
     } catch { return(Failed(MessageUtility.ServerError())); }
 }
        //public int GetLevel(string parentID)
        //{
        //    //return 0;

        //    var bll = new ItemCategoryService(this.CurrentUserInfo);

        //    if (string.IsNullOrEmpty(parentID) || parentID == "-99")
        //    {
        //        return 0;
        //    }
        //    else
        //    {
        //        var parent = bll.GetItemCategoryById(parentID);
        //        if (parentID != null)
        //        {
        //            return GetLevel(parent.Parent_Id) + 1;
        //        }
        //    }
        //    return 0;
        //}

        public int GetLevel(string parentID, List <ItemCategoryInfo> list)
        {
            //return 0;

            var bll = new ItemCategoryService(this.CurrentUserInfo);

            if (string.IsNullOrEmpty(parentID) || parentID == "-99")
            {
                return(0);
            }
            else
            {
                var parent = list.FirstOrDefault(x => x.Item_Category_Id == parentID);
                //parent = bll.GetItemCategoryById(parentID);
                if (parentID != null)
                {
                    if (parent == null)
                    {
                        return(1);
                    }
                    return(GetLevel(parent.Parent_Id, list) + 1);
                }
            }
            return(0);
        }
示例#4
0
        /// <summary>
        /// 获取第一级商品分类
        /// </summary>
        public string GetLevel1ItemCategory()
        {
            var responseData = new ResponseData();

            var categoryService = new ItemCategoryService(this.CurrentUserInfo);
            var content         = new GetLevel1ItemCategoryRespContentData(); //商品类别集合

            try
            {
                var ds = categoryService.GetLevel1ItemCategory(this.CurrentUserInfo.ClientID);
                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    content.categoryList = DataTableToObject.ConvertToList <GetLevel1ItemCategoryEntity>(ds.Tables[0]);
                }

                responseData.success = true;
                responseData.data    = content;
                return(responseData.ToJSON());
            }
            catch (Exception ex)
            {
                responseData.success = false;
                responseData.msg     = ex.ToString();
                return(responseData.ToJSON());
            }
        }
示例#5
0
 public async Task <JsonResult> GetAll()
 {
     try {
         var data = ItemCategoryService.GetAll();
         return(Success(ItemCategoryVM.MsToVMs(data)));
     } catch { return(Failed(MessageUtility.ServerError())); }
 }
        public string CategorySort(string pRequest)
        {
            var rp = pRequest.DeserializeJSONTo <APIRequest <CategorySortRP> >();
            var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo;
            var rd = new SaveSkuRD();//返回值


            var service = new ItemCategoryService(loggingSessionInfo);//保存到商品分类表

            //  var skuPropServer = new SkuPropServer(loggingSessionInfo);//保存到T_Sku_Property

            if (rp.Parameters.CategoryList == null)
            {
                throw new APIException("缺少参数【CategoryList】或参数值为空")
                      {
                          ErrorCode = 135
                      };
            }


            foreach (var item in rp.Parameters.CategoryList)
            {
                service.SetItemCategoryDisplayIndex(loggingSessionInfo, item.Item_Category_Id, item.DisplayIndex == null ? 0 : (int)item.DisplayIndex);
            }



            var rsp = new SuccessResponse <IAPIResponseData>(rd);

            return(rsp.ToJSON());
        }
示例#7
0
        /// <summary>
        /// 切换商品分类状态
        /// </summary>
        protected string ToggoleItemCategoryStatus()
        {
            // string res = "{success:false}";
            var    rsp      = new ResponseData();
            string checkRes = "";

            var bll    = new ItemCategoryService(this.CurrentUserInfo);
            var id     = this.Request("id");
            var status = this.Request("status");
            var bat_id = this.Request("bat_id");

            if (!string.IsNullOrWhiteSpace(id))
            {
                var bllItem = new ItemService(this.CurrentUserInfo);
                if (bllItem.GetItemCountByCategory(id, bat_id) > 0)
                {
                    rsp.success = false;
                    rsp.msg     = "该" + bat_id == "1" ? "分类" : "分组" + "下有商品,请先处理商品状态";
                }
                else
                {
                    bll.SetItemCategoryStatus(CurrentUserInfo, id, status, out checkRes);

                    if (!string.IsNullOrEmpty(checkRes))
                    {
                        rsp.success = false;
                        rsp.msg     = checkRes;
                    }
                    else
                    {
                        rsp.success = true;
                    }
                }
                #region 原来逻辑  20160103 wujx 屏蔽
                //if (bllItem.SearchItemList(null, null, id, null, null, null, 1, 0) != null)//判断该分类下是否有商品
                //{
                //    bll.SetItemCategoryStatus(CurrentUserInfo, id, status, out checkRes);

                //    if (!string.IsNullOrEmpty(checkRes))
                //    {
                //        // res = "{success:false,msg:\"" + checkRes + "\"}";
                //        rsp.success = false;
                //        rsp.msg = checkRes;
                //    }
                //    else
                //    {
                //        // res = "{success:true}";
                //        rsp.success = true;
                //    }
                //}
                //else
                //{
                //    rsp.success = false;
                //    rsp.msg = "该分类下有商品,请先处理商品状态";
                //}
                #endregion
            }
            return(rsp.ToJSON());
        }
示例#8
0
        /// <summary>
        /// 保存数据
        /// </summary>
        protected string UpdateItemCategory()
        {
            var bll  = new ItemCategoryService(this.CurrentUserInfo);
            var data = this.DeserializeJSONContent <ItemCategoryInfo>();
            var rsp  = new ResponseData();

            if (data != null)
            {
                IList <ItemCategoryInfo> listdata = bll.GetItemCagegoryList("", "");//获取所有类别

                if (Searchtype(listdata, data.Item_Category_Id, data.Parent_Id))
                {
                    rsp.success = false;
                    rsp.msg     = "上级分类不能选择自身下级";
                    return(rsp.ToJSON());
                }

                if (CheckCategoryNameIsExist(data.Item_Category_Id, data.Item_Category_Name, listdata))
                {
                    rsp.success = false;
                    rsp.msg     = "商品品类不能重复";
                    return(rsp.ToJSON());
                }

                if (string.IsNullOrWhiteSpace(data.Item_Category_Code))
                {
                    rsp.success = false;
                    rsp.msg     = "类型编码不能为空";
                    return(rsp.ToJSON());
                }
                if (string.IsNullOrWhiteSpace(data.Status))
                {
                    rsp.success = false;
                    rsp.msg     = "状态不能为空";
                    return(rsp.ToJSON());
                }
                if (string.IsNullOrWhiteSpace(data.Parent_Id))
                {
                    rsp.success = false;
                    rsp.msg     = "上级分类不能为空";
                    return(rsp.ToJSON());
                }

                data.Create_User_Id   = CurrentUserInfo.CurrentUser.User_Id;
                data.Create_Time      = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                data.Create_User_Name = CurrentUserInfo.CurrentUser.User_Name;
                data.CustomerID       = CurrentUserInfo.CurrentUser.customer_id;

                bll.SetItemCategoryInfo(this.CurrentUserInfo, data);
            }

            rsp.success = true;
            rsp.msg     = "保存成功";

            //
            return(rsp.ToJSON());
        }
示例#9
0
        /// <summary>
        /// 获取未打包的商品类别数量
        /// </summary>
        /// <param name="Customer_Id">客户标识</param>
        /// <param name="User_Id">用户标识</param>
        /// <param name="Unit_Id">组织标识</param>
        /// <returns></returns>
        public int GetItemCategoryNotPackagedCount(string Customer_Id, string User_Id, string Unit_Id)
        {
            LoggingSessionInfo loggingSessionInfo = GetLoggingSessionInfo(Customer_Id, User_Id, Unit_Id);
            int iCount = 0;
            ItemCategoryService itemCategoryService = new ItemCategoryService();

            iCount = itemCategoryService.GetItemCategoryNotPackagedCount(loggingSessionInfo);
            return(iCount);
        }
示例#10
0
        /// <summary>
        /// 需要打包的Item category集合
        /// </summary>
        /// <param name="Customer_Id">客户标识</param>
        /// <param name="User_Id">用户标识</param>
        /// <param name="Unit_Id">组织标识</param>
        /// <returns>未打包的商品集合</returns>
        public IList <ItemCategoryInfo> GetItemCategoryListPackaged(string Customer_Id, string User_Id, string Unit_Id)
        {
            IList <ItemCategoryInfo> itemCategoryInfoList = new List <ItemCategoryInfo>();
            LoggingSessionInfo       loggingSessionInfo   = GetLoggingSessionInfo(Customer_Id, User_Id, Unit_Id);
            ItemCategoryService      itemCategoryService  = new ItemCategoryService();

            itemCategoryInfoList = itemCategoryService.GetItemCategoryListPackaged(loggingSessionInfo);
            return(itemCategoryInfoList);
        }
示例#11
0
        /// <summary>
        /// 更新Item表打包标识方法
        /// </summary>
        /// <param name="Customer_Id">客户标识</param>
        /// <param name="User_Id">用户标识</param>
        /// <param name="Unit_Id">组织标识</param>
        /// <param name="bat_id">批次号</param>
        /// <returns>true=成功,false=失败</returns>
        public bool SetItemCategoryIfFlagInfo(string Customer_Id, string User_Id, string Unit_Id, string bat_id)
        {
            LoggingSessionInfo loggingSessionInfo = GetLoggingSessionInfo(Customer_Id, User_Id, Unit_Id);
            bool bReturn = false;
            ItemCategoryService itemCategoryService = new ItemCategoryService();

            bReturn = itemCategoryService.SetItemCategoryIfFlagInfo(loggingSessionInfo, bat_id);
            return(bReturn);
        }
 public InventoryController()
 {
     context          = new ApplicationDbContext();
     itemService      = new ItemService(context);
     statusService    = new StatusService(context);
     supplierService  = new SupplierService(context);
     categoryService  = new ItemCategoryService(context);
     userService      = new UserService(context);
     itemPriceService = new ItemPriceService(context);
 }
示例#13
0
        /// <summary>
        /// 切换商品分类状态
        /// </summary>
        protected void ToggoleItemCategoryStatus()
        {
            var bll    = new ItemCategoryService(this.CurrentUserInfo);
            var id     = this.Request("id");
            var status = this.Request("status");

            if (!string.IsNullOrWhiteSpace(id))
            {
                string res = "";
                bll.SetItemCategoryStatus(CurrentUserInfo, id, status, out res);
            }
        }
示例#14
0
 public async Task <JsonResult> Insert()
 {
     try {
         var id   = Guid.NewGuid();
         var Name = Request.Form["name"].ToString();
         if (ItemCategoryService.Insert(id, Name))
         {
             return(Success(id.ToString()));
         }
         return(Failed(MessageUtility.ServerError()));
     } catch { return(Failed(MessageUtility.ServerError())); }
 }
示例#15
0
 public async Task <JsonResult> Update()
 {
     try {
         var id      = Guid.Parse(Request.Form["id"]);
         var name    = Request.Form["name"];
         var archive = Boolean.Parse(Request.Form["archive"]);
         if (ItemCategoryService.Update(id, name, archive))
         {
             return(Success(id.ToString()));
         }
         return(Failed(MessageUtility.ServerError()));
     } catch { return(Failed(MessageUtility.ServerError())); }
 }
示例#16
0
        public string DeleteItemCategoryArea()
        {
            var responseData = new ResponseData();

            var groupID = FormatParamValue(Request("groupId"));

            var itemCategoryService = new ItemCategoryService(this.CurrentUserInfo);

            itemCategoryService.DeleteItemCategoryAreaData(groupID);
            itemCategoryService.DeleteItemCategoryAreaGroupData(groupID);
            responseData.success = true;
            responseData.msg     = "删除成功";
            return(responseData.ToJSON());
        }
        protected override TreeNodes GetNodes(string pParentNodeID)
        {
            string status = "";

            if (Request("Status") != null && Request("Status") != "")
            {
                status = Request("Status");
            }
            string bat_id = "";

            if (Request("bat_id") != null && Request("bat_id") != "")
            {
                bat_id = Request("bat_id");
            }
            //获取数据
            var bll        = new ItemCategoryService(this.CurrentUserInfo);
            var list       = bll.GetItemCagegoryList(status, bat_id);
            var parentList = bll.GetItemCagegoryList(status, "all");

            //组织数据
            TreeNodes nodes = new TreeNodes();

            if (list != null && list.Count > 0)
            {
                foreach (var item in list)
                {
                    TreeNode node = new TreeNode();
                    node.ID = item.Item_Category_Id;
                    if (string.IsNullOrWhiteSpace(item.Parent_Id) == false && item.Parent_Id != "-99")
                    {
                        node.ParentID = item.Parent_Id;
                    }
                    node.Text         = item.Item_Category_Name;
                    node.Status       = item.Status;
                    node.IsLeaf       = true;
                    node.NodeLevel    = GetLevel(item.Parent_Id, parentList.ToList());
                    node.DisplayIndex = item.DisplayIndex == null ? 0 : (int)item.DisplayIndex;//排序字段,新加

                    //新添加的节点

                    node.create_time        = string.IsNullOrEmpty(item.Create_Time) ? "" :  DateTime.Parse(item.Create_Time).ToString("yyyy/MM/dd");//Convert.ToDateTime(item.Create_Time).ToShortDateString();
                    node.ImageUrl           = item.ImageUrl;
                    node.PromotionItemCount = item.PromotionItemCount;
                    nodes.Add(node);
                }
            }
            //?
            return(nodes);
        }
        public void TestInitialize()
        {
            context                = new ApplicationDbContext();
            itemRepository         = new ItemRepository(context);
            itemcategoryService    = new ItemCategoryService(context);
            itemcategoryRepository = new ItemCategoryRepository(context);

            //create new ItemCategory object and save into DB
            ItemCategory ic = itemcategoryRepository.Save(new ItemCategory()
            {
                ItemCategoryId  = IdService.GetNewItemCategoryId(context),
                Name            = "TEST",
                CreatedDateTime = DateTime.Now
            });
        }
示例#19
0
        public void SyncWelfareType()
        {
            var interfaceName      = "syncwelFarePreferentialType";
            var loggingSessionInfo = BaseService.GetLoggingSession();
            var categoryService    = new ItemCategoryService(loggingSessionInfo);

            var dsTypes     = new DataSet();
            var preTypeList = new PreferentialTypeList();

            preTypeList.preferentialtypelist = new List <PreferentialType>();

            //更新接口同步表
            var queryList = UpdateInterfaceTimestamp(interfaceName, loggingSessionInfo);

            if (queryList != null && queryList.Length > 0)
            {
                //存在,根据日期条件查询
                dsTypes = categoryService.GetSynWelfareTypeList(queryList.FirstOrDefault().LatestTime.ToString());
            }
            else
            {
                //不存在,查询所有数据
                dsTypes = categoryService.GetSynWelfareTypeList(string.Empty);
            }

            if (dsTypes != null && dsTypes.Tables.Count > 0 && dsTypes.Tables[0].Rows.Count > 0)
            {
                preTypeList.preferentialtypelist = DataTableToObject.ConvertToList <PreferentialType>(dsTypes.Tables[0]);

                //上传数据
                var content = preTypeList.ToJSON();
                var result  = UploadData(interfaceName, content);

                //写入接口日志
                var logEntity = new ZInterfaceLogEntity()
                {
                    LogId         = Utils.NewGuid(),
                    InterfaceName = interfaceName,
                    Params        = content,
                    ResultCode    = result.code,
                    ResultDesc    = result.description
                };

                InsertInterfaceLog(logEntity, loggingSessionInfo);
            }
        }
        public ActionResult Save(ItemCategoryViewModel model)
        {
            bool status = false;

            statusService       = new StatusService(context);
            itemcategoryService = new ItemCategoryService(context);
            userService         = new UserService(context);

            ItemCategory s = new ItemCategory();

            if (itemcategoryService.FindItemCategoryByItemCategoryId(model.ItemCategoryId) == null)
            {
                //new item category
                s.ItemCategoryId = IdService.GetNewItemCategoryId(context);
                //assign user info
                s.CreatedDateTime = DateTime.Now;
                s.CreatedBy       = userService.FindUserByEmail(CurrentUserName);
            }

            else
            {
                //existing ItemCategory
                s = itemcategoryService.FindItemCategoryByItemCategoryId(model.ItemCategoryId);

                //assign user info into update fields
                s.UpdatedDateTime = DateTime.Now;
                s.UpdatedBy       = userService.FindUserByEmail(CurrentUserName);
            }

            //assign item category info
            s.Name        = model.Name;
            s.Description = model.Description;
            s.Status      = statusService.FindStatusByStatusId(model.Status);

            //save info to database
            if (itemcategoryService.Save(s) != null)
            {
                status = true;
            }

            //return RedirectToAction("Index", "ItemCategory");
            return(new JsonResult {
                Data = new { status = status }
            });
        }
        /// <summary>
        /// 获取子节点数据
        /// </summary>
        /// <param name="pParentNodeID">父节点ID</param>
        /// <returns></returns>
        protected override TreeNodes GetNodes(string pParentNodeID)
        {
            TreeNodes nodes = new TreeNodes();

            ItemCategoryService itemService = new ItemCategoryService(
                new SessionManager().CurrentUserLoginInfo);
            IList <ItemCategoryInfo> list = new List <ItemCategoryInfo>();

            string key     = string.Empty;
            string content = string.Empty;

            if (Request("node") != null && Request("node") != string.Empty)
            {
                key = Request("node").ToString().Trim();
            }

            if (key == "root" || key.Length == 0)
            {
                key = "-99";
            }
            list = itemService.GetItemCategoryListByParentId(key);

            var jsonData = new JsonData();

            jsonData.totalCount = list.Count.ToString();
            jsonData.data       = list;

            foreach (var item in list)
            {
                if (item.Status == "1")
                {
                    nodes.Add(item.Item_Category_Id, item.Item_Category_Name, item.Parent_Id, false);
                }
            }
            DataSet ds = itemService.GetItemsBytype(key);

            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0] != null)
            {
                foreach (DataRow item in ds.Tables[0].Rows)
                {
                    nodes.Add(item["item_id"].ToString(), item["item_name"].ToString(), key, false);
                }
            }
            return(nodes);
        }
示例#22
0
        public int GetLevel(string parentID)
        {
            var bll = new ItemCategoryService(this.CurrentUserInfo);

            if (string.IsNullOrEmpty(parentID) || parentID == "-99")
            {
                return(0);
            }
            else
            {
                var parent = bll.GetItemCategoryById(parentID);
                if (parentID != null)
                {
                    return(GetLevel(parent.Parent_Id) + 1);
                }
            }
            return(0);
        }
示例#23
0
        /// <summary>
        /// 删除商品分类信息
        /// </summary>
        public string DeleteItemCategory()
        {
            var service = new ItemCategoryService(CurrentUserInfo);

            string content      = string.Empty;
            string error        = "";
            var    responseData = new ResponseData();

            string key = string.Empty;

            if (FormatParamValue(Request("ids")) != null && FormatParamValue(Request("ids")) != string.Empty)
            {
                key = FormatParamValue(Request("ids")).ToString().Trim();
            }

            if (key == null || key.Trim().Length == 0)
            {
                responseData.success = false;
                responseData.msg     = "商品分类ID不能为空";
                return(responseData.ToJSON());
            }

            var status = "-1";

            if (FormatParamValue(Request("status")) != null && FormatParamValue(Request("status")) != string.Empty)
            {
                status = FormatParamValue(Request("status")).ToString().Trim();
            }

            string[] ids = key.Split(',');
            foreach (var id in ids)
            {
                //删除商品分类信息
                string res = "";
                service.SetItemCategoryStatus(CurrentUserInfo, key, status, out res);
            }

            responseData.success = true;
            responseData.msg     = error;

            content = responseData.ToJSON();
            return(content);
        }
示例#24
0
        /// <summary>
        /// 根据ID获取商品分类信息
        /// </summary>
        public string GetItemCategoryByID()
        {
            var itemCategoryService  = new ItemCategoryService(CurrentUserInfo);
            ItemCategoryInfo data    = new ItemCategoryInfo();
            string           content = string.Empty;

            string key = string.Empty;

            if (Request("ItemCategoryId") != null && Request("ItemCategoryId") != string.Empty)
            {
                key = Request("ItemCategoryId").ToString().Trim();
            }

            data = itemCategoryService.GetItemCategoryById(key);

            var jsonData = new JsonData();

            jsonData.totalCount = data == null ? "0" : "1";
            jsonData.data       = data;

            content = jsonData.ToJSON();
            return(content);
        }
示例#25
0
        /// <summary>
        /// 商品分类查询
        /// </summary>
        public string GetItemCategory()
        {
            var responseData = new ResponseData();

            //请求参数
            var categoryName = FormatParamValue(Request("categoryName"));
            var pageIndex    = Utils.GetIntVal(FormatParamValue(Request("pageIndex")));
            var pageSize     = Utils.GetIntVal(FormatParamValue(Request("pageSize")));

            if (pageSize <= 0)
            {
                pageSize = 15;
            }

            var categoryService = new ItemCategoryService(this.CurrentUserInfo);
            var content         = new GetItemCategoryRespContentData(); //商品类别集合

            try
            {
                var ds = categoryService.GetItemCategoryList(this.CurrentUserInfo.ClientID, categoryName, pageIndex, pageSize);
                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    content.categoryList = DataTableToObject.ConvertToList <GetItemCategoryEntity>(ds.Tables[0]);
                    content.totalCount   = categoryService.GetItemCategoryCount(this.CurrentUserInfo.ClientID, categoryName);
                }

                responseData.success = true;
                responseData.data    = content;
                return(responseData.ToJSON());
            }
            catch (Exception ex)
            {
                responseData.success = false;
                responseData.msg     = ex.ToString();
                return(responseData.ToJSON());
            }
        }
示例#26
0
        /// <summary>
        /// 获取商品分类
        /// </summary>
        public string GetItemCategoryListData()
        {
            var form = Request("form").DeserializeJSONTo <ItemCategoryQueryEntity>();

            var itemCategoryService  = new ItemCategoryService(CurrentUserInfo);
            ItemCategoryInfo data    = new ItemCategoryInfo();
            string           content = string.Empty;

            string item_category_code = FormatParamValue(form.item_category_code);
            string item_category_name = FormatParamValue(form.item_category_name);
            string pyzjm = FormatParamValue(form.pyzjm);
            string item_category_status = FormatParamValue(Request("item_category_status"));
            string item_category_id     = FormatParamValue(Request("item_category_id"));
            int    maxRowCount          = PageSize;
            int    startRowIndex        = Utils.GetIntVal(Request("start"));

            string key = string.Empty;

            if (Request("item_category_id") != null && Request("item_category_id") != string.Empty)
            {
                key = Request("item_category_id").ToString().Trim();
            }

            data = itemCategoryService.SearchItemCategoryList(
                item_category_code, item_category_name, pyzjm, item_category_status,
                maxRowCount, startRowIndex, item_category_id);

            var jsonData = new JsonData();

            jsonData.totalCount = data.ItemCategoryInfoList.Count.ToString();
            jsonData.data       = data.ItemCategoryInfoList;

            content = string.Format("{{\"totalCount\":{1},\"topics\":{0}}}",
                                    data.ItemCategoryInfoList.ToJSON(),
                                    data.ICount);
            return(content);
        }
示例#27
0
        /// <summary>
        /// 保存数据
        /// </summary>
        protected string UpdateItemCategory()
        {
            var bll  = new ItemCategoryService(this.CurrentUserInfo);
            var data = this.DeserializeJSONContent <ItemCategoryInfo>();
            var rsp  = new ResponseData();

            if (data != null)
            {
                if (string.IsNullOrWhiteSpace(data.Item_Category_Code))
                {
                    rsp.success = false;
                    rsp.msg     = "类型编码不能为空";
                    return(rsp.ToJSON());
                }
                if (string.IsNullOrWhiteSpace(data.Status))
                {
                    rsp.success = false;
                    rsp.msg     = "状态不能为空";
                    return(rsp.ToJSON());
                }
                if (string.IsNullOrWhiteSpace(data.Parent_Id))
                {
                    rsp.success = false;
                    rsp.msg     = "上级分类不能为空";
                    return(rsp.ToJSON());
                }
                data.Create_User_Id   = CurrentUserInfo.CurrentUser.User_Id;
                data.Create_Time      = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                data.Create_User_Name = CurrentUserInfo.CurrentUser.User_Name;
                data.CustomerID       = CurrentUserInfo.CurrentUser.customer_id;
                //
                bll.SetItemCategoryInfo(this.CurrentUserInfo, data);
            }
            //
            return(rsp.ToJSON());
        }
示例#28
0
        public string SaveEventItemArea()
        {
            var responseData = new ResponseData();

            var itemArea  = this.CurrentContext.Request["eventItemList"].DeserializeJSONTo <List <SaveItemArea> >();
            var _areaFlag = this.CurrentContext.Request["areaFlag"] == null ? "eventList" : this.CurrentContext.Request["areaFlag"].ToString();

            #region
            if (itemArea != null)
            {
                var    itemAreaBll = new MHItemAreaBLL(this.CurrentUserInfo);
                var    homeBll     = new MobileHomeBLL(this.CurrentUserInfo);
                string customerId  = this.CurrentUserInfo.CurrentUser.customer_id;
                var    homeList    = homeBll.QueryByEntity(new MobileHomeEntity {
                    CustomerId = this.CurrentUserInfo.ClientID
                }, null);

                if (homeList != null && homeList.Length > 0)
                {
                    var    homeId         = homeList.FirstOrDefault().HomeId;
                    string itemAreaIdList = itemArea.Where(item => !string.IsNullOrEmpty(item.itemAreaId.ToString())).Aggregate("", (current, item) => current + "'" + item.itemAreaId.ToString() + "',");
                    //根据ItemAreaId删除MHItemArea中旧数据(not in itemAreaIdList)
                    if (itemAreaIdList != "")
                    {
                        var itemCategoryService = new ItemCategoryService(this.CurrentUserInfo);
                        itemCategoryService.UpdateMHItemAreaData(itemAreaIdList, customerId, _areaFlag);
                    }

                    //根据ItemAreaId判断是新增还是更新MHItemArea数据
                    foreach (var item in itemArea)
                    {
                        if (string.IsNullOrEmpty(item.itemAreaId.ToString()))
                        {
                            var entity = new MHItemAreaEntity()
                            {
                                ItemAreaId   = Guid.NewGuid(),
                                HomeId       = homeId,
                                IsUrl        = item.isUrl,
                                EventId      = item.eventId,
                                ItemId       = item.itemId,
                                areaFlag     = _areaFlag,
                                DisplayIndex = item.displayIndex,
                            };
                            itemAreaBll.Create(entity);
                        }
                        else
                        {
                            var entity = new MHItemAreaEntity()
                            {
                                ItemAreaId   = item.itemAreaId,
                                HomeId       = homeId,
                                IsUrl        = item.isUrl,
                                EventId      = item.eventId,
                                ItemId       = item.itemId,
                                areaFlag     = _areaFlag,
                                DisplayIndex = item.displayIndex,
                            };
                            itemAreaBll.Update(entity);
                        }
                    }
                }
            }
            #endregion

            responseData.success = true;
            responseData.msg     = "更新成功";
            return(responseData.ToJSON());
        }
示例#29
0
        public string SaveAds()
        {
            var responseData = new ResponseData();
            var itemAds      = this.CurrentContext.Request["adList"].DeserializeJSONTo <List <SaveMHAdArea> >();

            #region
            if (itemAds != null)
            {
                var adAreaBll = new MHAdAreaBLL(this.CurrentUserInfo);
                var homeBll   = new MobileHomeBLL(this.CurrentUserInfo);
                var homeList  = homeBll.QueryByEntity(new MobileHomeEntity {
                    CustomerId = this.CurrentUserInfo.ClientID
                }, null);

                string customerId = this.CurrentUserInfo.CurrentUser.customer_id;
                if (homeList != null && homeList.Length > 0)
                {
                    var homeId = homeList.FirstOrDefault().HomeId;

                    string adsIdList = itemAds.Where(item => !string.IsNullOrEmpty(item.adId.ToString())).Aggregate("", (current, item) => current + "'" + item.adId.ToString() + "',");
                    //根据AdAreaId删除MHAdArea中旧数据(not in adsList)
                    var itemCategoryService = new ItemCategoryService(this.CurrentUserInfo);
                    if (adsIdList != "")
                    {
                        itemCategoryService.UpdateMHAdAreaData(adsIdList, customerId);
                    }
                    else
                    {
                        itemCategoryService.DeleteMHAdAreaData(customerId);
                    }

                    //根据AdAreaId判断是新增还是更新MHAdArea数据
                    foreach (var item in itemAds)
                    {
                        if (string.IsNullOrEmpty(item.adId.ToString()))
                        {
                            var entity = new MHAdAreaEntity()
                            {
                                AdAreaId     = Guid.NewGuid(),
                                HomeId       = homeId,
                                ImageUrl     = item.imageUrl,
                                ObjectId     = item.objectId,
                                ObjectTypeId = item.typeId,
                                DisplayIndex = item.displayIndex,
                                Url          = item.url
                            };
                            adAreaBll.Create(entity);
                        }
                        else
                        {
                            var entity = new MHAdAreaEntity()
                            {
                                AdAreaId     = item.adId,
                                HomeId       = homeId,
                                ImageUrl     = item.imageUrl,
                                ObjectId     = item.objectId,
                                ObjectTypeId = item.typeId,
                                DisplayIndex = item.displayIndex,
                                Url          = item.url
                            };
                            adAreaBll.Update(entity);
                        }
                    }
                }
            }
            #endregion
            responseData.success = true;
            responseData.msg     = "更新成功";
            return(responseData.ToJSON());
        }
 public ItemCategoryAPIController()
 {
     context             = new ApplicationDbContext();
     itemcategoryService = new ItemCategoryService(context);
 }