Esempio n. 1
0
        public IHttpActionResult PutProductCategoryEntity(string id, ProductCategoryEntity productCategoryEntity)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != productCategoryEntity.ID)
            {
                return(BadRequest());
            }

            db.Entry(productCategoryEntity).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ProductCategoryEntityExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Esempio n. 2
0
        /// <summary>
        /// 查询分页
        /// </summary>
        /// <returns></returns>
        public ActionResult GetPage()
        {
            string CompanyID = WebUtil.GetFormValue <string>("CompanyID");
            int    PageIndex = WebUtil.GetFormValue <int>("PageIndex", 1);
            int    PageSize  = WebUtil.GetFormValue <int>("PageSize", 10);

            string CateNum  = WebUtil.GetFormValue <string>("CateNum");
            string CateName = WebUtil.GetFormValue <string>("CateName");
            string Remark   = WebUtil.GetFormValue <string>("Remark");

            ProductCategoryEntity entity = new ProductCategoryEntity();

            entity.CateNum  = CateNum;
            entity.CateName = CateName;
            entity.Remark   = Remark;

            PageInfo pageInfo = new PageInfo();

            pageInfo.PageIndex = PageIndex;
            pageInfo.PageSize  = PageSize;

            ProductCategoryProvider      provider = new ProductCategoryProvider(CompanyID);
            List <ProductCategoryEntity> list     = provider.GetList(entity, ref pageInfo);

            DataListResult <ProductCategoryEntity> result = new DataListResult <ProductCategoryEntity>()
            {
                Code = (int)EResponseCode.Success, Message = "响应成功", Result = list, PageInfo = pageInfo
            };

            return(Content(JsonHelper.SerializeObject(result)));
        }
Esempio n. 3
0
        public async Task <Result <ProductCategoriesErrorCodes> > DeleteAsync(string id, byte[] timestamp)
        {
            using (var context = _contextFactory.CreateDataContext())
            {
                var entity = new ProductCategoryEntity()
                {
                    Id = id, Timestamp = timestamp
                };

                context.Attach(entity);
                context.ProductCategories.Remove(entity);

                try
                {
                    await context.SaveChangesAsync();

                    return(new Result <ProductCategoriesErrorCodes>());
                }
                catch (DbUpdateConcurrencyException e)
                {
                    if (e.Message.Contains(DoesNotExistException))
                    {
                        return(new Result <ProductCategoriesErrorCodes>(ProductCategoriesErrorCodes.DoesNotExist));
                    }

                    throw;
                }
            }
        }
        /// <summary>
        /// 查询根节点
        /// </summary>
        /// <returns></returns>
        private ProductCategoryEntity GetRoot()
        {
            string Key = string.Format(CacheKey.JOOSHOW_PRODUCTCATEGORY_CACHE, this.CompanyID);
            List <ProductCategoryEntity> listSource = GetList();

            if (listSource.IsNullOrEmpty())
            {
                ProductCategoryEntity entity = new ProductCategoryEntity();
                entity.SnNum      = ConvertHelper.NewGuid();
                entity.CateNum    = new TNumProvider(this.CompanyID).GetSwiftNum(typeof(ProductCategoryEntity), 5);
                entity.IsDelete   = (int)EIsDelete.NotDelete;
                entity.CreateTime = DateTime.Now;
                entity.CateName   = "Root";
                entity.ParentNum  = "";
                entity.CompanyID  = this.CompanyID;
                entity.Left       = 1;
                entity.Right      = 2;
                entity.IncludeAll();
                int line = this.ProductCategory.Add(entity);
                if (line > 0)
                {
                    CacheHelper.Remove(Key);
                }
            }
            listSource = GetList();

            ProductCategoryEntity result = listSource.First(item => item.ParentNum.IsEmpty());

            return(result);
        }
Esempio n. 5
0
        /// <summary>
        /// 新增产品类别
        /// </summary>
        /// <returns></returns>
        public ActionResult Add()
        {
            string CateNum               = WebUtil.GetFormValue <string>("CateNum");
            string CompanyID             = WebUtil.GetFormValue <string>("CompanyID");
            string CateName              = WebUtil.GetFormValue <string>("CateName");
            string Remark                = WebUtil.GetFormValue <string>("Remark");
            string CreateUser            = WebUtil.GetFormValue <string>("CreateUser");
            string ParentNum             = WebUtil.GetFormValue <string>("ParentNum");
            ProductCategoryEntity entity = new ProductCategoryEntity();

            entity.CateName   = CateName;
            entity.IsDelete   = (int)EIsDelete.NotDelete;
            entity.CreateTime = DateTime.Now;
            entity.CreateUser = CreateUser;
            entity.Remark     = Remark;
            entity.ParentNum  = ParentNum;
            entity.CompanyID  = CompanyID;
            ProductCategoryProvider provider = new ProductCategoryProvider(CompanyID);
            int        line   = provider.Add(entity);
            DataResult result = new DataResult();

            if (line > 0)
            {
                result.Code    = (int)EResponseCode.Success;
                result.Message = "产品类别新增成功";
            }
            else
            {
                result.Code    = (int)EResponseCode.Exception;
                result.Message = "产品类别新增失败";
            }
            return(Content(JsonHelper.SerializeObject(result)));
        }
Esempio n. 6
0
        public ActionResult CateList()
        {
            string cateName  = WebUtil.GetFormValue <string>("cateName", string.Empty);
            int    pageIndex = WebUtil.GetFormValue <int>("pageIndex", 0);
            int    pageSize  = WebUtil.GetFormValue <int>("pageSize", 0);
            ProductCategoryProvider provider = new ProductCategoryProvider();
            ProductCategoryEntity   entity   = new ProductCategoryEntity();

            if (!cateName.IsEmpty())
            {
                entity.Begin <ProductCategoryEntity>()
                .Where <ProductCategoryEntity>("CateNum", ECondition.Like, "%" + cateName + "%")
                .Or <ProductCategoryEntity>("CateName", ECondition.Like, "%" + cateName + "%")
                .End <ProductCategoryEntity>()
                ;
            }
            PageInfo pageInfo = new PageInfo()
            {
                PageIndex = pageIndex, PageSize = pageSize
            };
            List <ProductCategoryEntity> list = provider.GetList(entity, ref pageInfo);

            list = list.IsNull() ? new List <ProductCategoryEntity>() : list;
            string     json       = ConvertJson.ListToJson <ProductCategoryEntity>(list, "data");
            JsonObject jsonObject = new JsonObject(json);

            this.ReturnJson.AddProperty("list", jsonObject);
            this.ReturnJson.AddProperty("RowCount", pageInfo.RowCount);
            return(Content(this.ReturnJson.ToString()));
        }
        /// <summary>
        /// 查询商品种类分页
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="pageInfo"></param>
        /// <returns></returns>
        public List <ProductCategoryEntity> GetList(ProductCategoryEntity entity, ref PageInfo pageInfo)
        {
            List <ProductCategoryEntity> listSource = GetList();

            if (listSource.IsNullOrEmpty())
            {
                return(listSource);
            }

            List <ProductCategoryEntity> listResult = listSource.Where(item => item.IsDelete == (int)EIsDelete.NotDelete).ToList();

            if (entity.CateNum.IsNotEmpty())
            {
                listResult = listResult.Where(item => item.CateNum.Contains(entity.CateNum)).ToList();
            }
            if (entity.CateName.IsNotEmpty())
            {
                listResult = listResult.Where(item => item.CateName.Contains(entity.CateName)).ToList();
            }
            if (entity.ParentNum.IsNotEmpty())
            {
                listResult = listResult.Where(item => item.ParentNum == entity.ParentNum).ToList();
            }
            int rowCount = listResult.Count();

            pageInfo.RowCount = rowCount;
            return(listResult.OrderBy(item => item.Depth).OrderBy(item => item.ID).Where(item => item.CateName != "Root").Skip((pageInfo.PageIndex - 1) * pageInfo.PageSize).Take(pageInfo.PageSize).ToList());
        }
        /// <summary>
        /// 查询所有的产品类别
        /// </summary>
        /// <returns></returns>
        public List <ProductCategoryEntity> GetList()
        {
            string Key = string.Format(CacheKey.JOOSHOW_PRODUCTCATEGORY_CACHE, this.CompanyID);

            List <ProductCategoryEntity> list = CacheHelper.Get(Key) as List <ProductCategoryEntity>;

            if (!list.IsNullOrEmpty())
            {
                return(list);
            }
            ProductCategoryEntity entity = new ProductCategoryEntity();

            entity.OrderBy(a => a.ID, EOrderBy.DESC);
            entity.IncludeAll();
            entity.Where(a => a.IsDelete == (int)EIsDelete.NotDelete)
            .And(a => a.CompanyID == this.CompanyID);
            list = this.ProductCategory.GetList(entity);
            if (!list.IsNullOrEmpty())
            {
                foreach (ProductCategoryEntity item in list)
                {
                    int depth = list.Where(a => a.Left <= item.Left && a.Right >= item.Right).Count();
                    item.Depth = depth;

                    if (item.ParentNum.IsNotEmpty())
                    {
                        ProductCategoryEntity parent = list.FirstOrDefault(a => a.SnNum == item.ParentNum);
                        item.ParentName = item != null && parent.CateName != "Root" ? parent.CateName : string.Empty;
                    }
                }
                CacheHelper.Insert(Key, list);
            }
            return(list);
        }
Esempio n. 9
0
        /// <summary>
        /// 在线库存报表
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="pageInfo"></param>
        /// <returns></returns>
        public List <LocalProductEntity> GetList(LocalProductEntity entity, ref PageInfo pageInfo)
        {
            entity.IncludeAll();
            ProductEntity ProEntity = new ProductEntity();

            // ProEntity.Include(a => new { Size = a.Size, AvgPrice = a.AvgPrice, CateNum = a.CateNum, CateName = a.CateName, MinNum = a.MinNum, MaxNum = a.MaxNum });

            ProEntity.Include(a => new { AvgPrice = a.AvgPrice, CateNum = a.CateNum, CateName = a.CateName, MinNum = a.MinNum, MaxNum = a.MaxNum });
            entity.Left <ProductEntity>(ProEntity, new Params <string, string>()
            {
                Item1 = "ProductNum", Item2 = "SnNum"
            });
            entity.OrderBy(a => a.ID, EOrderBy.DESC);
            int rowCount = 0;
            List <LocalProductEntity> listResult = this.LocalProduct.GetList(entity, pageInfo.PageSize, pageInfo.PageIndex, out rowCount);

            pageInfo.RowCount = rowCount;

            List <ProductCategoryEntity> listCates = new ProductCategoryProvider().GetList();

            listCates = listCates.IsNull() ? new List <ProductCategoryEntity>() : listCates;
            if (!listResult.IsNullOrEmpty())
            {
                foreach (LocalProductEntity item in listResult)
                {
                    if (item.CateName.IsEmpty())
                    {
                        ProductCategoryEntity cate = listCates.FirstOrDefault(a => a.CateNum == item.CateNum);
                        item.CateName = cate == null ? "" : cate.CateName;
                    }
                }
            }
            return(listResult);
        }
Esempio n. 10
0
        private string GetList(HttpContext context)
        {
            ProductCategoryEntity entity = new ProductCategoryEntity();

            entity.deleted  = false;
            entity.Category = context.Request["category"];
            entity.ParentId = context.Request["parentid"].ToNullable <int>();


            Pagination pagination = new Pagination();

            pagination.PageIndex = Convert.ToInt32(HttpContext.Current.Request["pageIndex"].ToInt(1));
            pagination.PageSize  = Convert.ToInt32(HttpContext.Current.Request["pageSize"].ToInt(3));
            pagination.IsPaging  = (bool)context.Request["isPaging"].To <bool>(false);

            ProductCategoryService       service = new ProductCategoryService();
            List <ProductCategoryEntity> list    = service.GetList(entity, pagination);

            var resultObj = new
            {
                page = pagination,
                data = list,
                code = 10000
            };

            //将对象序列化成为JSON格式
            return(Newtonsoft.Json.JsonConvert.SerializeObject(resultObj));
        }
        /// <summary>
        /// 根据产品类别删除删除
        /// </summary>
        /// <param name="cateNum"></param>
        /// <returns></returns>
        public int Delete(IEnumerable <string> list)
        {
            string Key = string.Format(CacheKey.JOOSHOW_PRODUCTCATEGORY_CACHE, this.CompanyID);

            using (TransactionScope ts = new TransactionScope())
            {
                int line = 0;

                List <ProductCategoryEntity> listSource = GetList();
                listSource = listSource.IsNull() ? new List <ProductCategoryEntity>() : listSource;

                foreach (string item in list)
                {
                    ProductCategoryEntity parent = listSource.FirstOrDefault(a => a.SnNum == item);
                    int rightValue = parent.Right;
                    int leftValue  = parent.Left;

                    ProductCategoryEntity delCategory = new ProductCategoryEntity();
                    delCategory.IsDelete = (int)EIsDelete.Deleted;
                    delCategory.IncludeIsDelete(true);
                    delCategory.Where(a => a.Left >= leftValue)
                    .And(a => a.Right <= rightValue)
                    .And(a => a.CompanyID == this.CompanyID)
                    ;
                    line += this.ProductCategory.Update(delCategory);

                    List <ProductCategoryEntity> listNodes = listSource.Where(a => a.Left > leftValue).ToList();
                    if (!listNodes.IsNullOrEmpty())
                    {
                        foreach (ProductCategoryEntity cate in listNodes)
                        {
                            cate.Left = cate.Left - (rightValue - leftValue + 1);
                            cate.IncludeLeft(true);
                            cate.Where(a => a.SnNum == cate.SnNum).And(a => a.CompanyID == this.CompanyID);
                            line += this.ProductCategory.Update(cate);
                        }
                    }

                    listNodes = listSource.Where(a => a.Right > rightValue).ToList();
                    if (!listNodes.IsNullOrEmpty())
                    {
                        foreach (ProductCategoryEntity cate in listNodes)
                        {
                            cate.Right = cate.Right - (rightValue - leftValue + 1);
                            cate.IncludeRight(true);
                            cate.Where(a => a.SnNum == cate.SnNum).And(a => a.CompanyID == this.CompanyID);
                            line += this.ProductCategory.Update(cate);
                        }
                    }
                }
                if (line > 0)
                {
                    CacheHelper.Remove(Key);
                }
                ts.Complete();
                return(line);
            }
        }
 /// <summary>
 /// Removes a product category from the database.
 /// The function cannot remove a product category if
 ///     the parameter is null, or
 ///     the product category is set to one or more product.
 /// </summary>
 /// <param name="category">The Id property selects the category.</param>
 /// <returns></returns>
 public static bool Remove(ProductCategoryEntity category)
 {
     if ((category == null) ||
         (ProductProvider.IsExist(p => p.CategoryId == category.Id)))
     {
         return(false);
     }
     return(DatabaseConnection.Remove <ProductCategoryEntity>(p => p.Id == category.Id));
 }
 /// <summary>
 /// Adds a new product category to the database
 /// The function cannot add a category if
 ///     the parameter is null, or
 ///     the category name is empty, or
 ///     the category name already exists.
 /// </summary>
 /// <param name="category"></param>
 /// <returns></returns>
 public static bool Add(ProductCategoryEntity category)
 {
     if ((category == null) ||
         (string.IsNullOrWhiteSpace(category.Category)) ||
         (DatabaseConnection.IsExist <ProductCategoryEntity>(p => p.Category == category.Category)))
     {
         return(false);
     }
     return(DatabaseConnection.Add <ProductCategoryEntity>(category));
 }
 /// <summary>
 /// Modifies a product category in the database.
 /// The function cannot modify a category if
 ///     the parameter is null, or
 ///     the new category name is empty, or
 ///     the new category name already exists with different Id.
 /// </summary>
 /// <param name="category">The Id property selects the category.</param>
 /// <returns></returns>
 public static bool Modify(ProductCategoryEntity category)
 {
     if ((category == null) ||
         (string.IsNullOrWhiteSpace(category.Category)) ||
         (DatabaseConnection.IsExist <ProductCategoryEntity>(p => p.Id != category.Id && p.Category == category.Category)))
     {
         return(false);
     }
     return(DatabaseConnection.Modify <ProductCategoryEntity>(category, p => p.Id == category.Id));
 }
        /// <summary>
        /// 查询族谱路径
        /// </summary>
        /// <param name="SnNum"></param>
        /// <returns></returns>
        public List <ProductCategoryEntity> GetParentList(string SnNum)
        {
            ProductCategoryEntity        node       = GetSingle(SnNum);
            List <ProductCategoryEntity> listSource = GetList();

            if (node != null && listSource != null)
            {
                return(listSource.Where(item => item.Left <= node.Left && item.Right >= node.Right).ToList());
            }
            return(null);
        }
Esempio n. 16
0
        /// <summary>
        /// 添加产品类别
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public int Add(ProductCategoryEntity entity)
        {
            entity.IncludeAll();
            int line = this.ProductCategory.Add(entity);

            if (line > 0)
            {
                CacheHelper.Remove(CacheKey.JOOSHOW_PRODUCTCATEGORY_CACHE);
            }
            return(line);
        }
Esempio n. 17
0
        public IHttpActionResult GetProductCategoryEntity(string id)
        {
            ProductCategoryEntity productCategoryEntity = db.CategoryEntities.Find(id);

            if (productCategoryEntity == null)
            {
                return(NotFound());
            }

            return(Ok(productCategoryEntity));
        }
Esempio n. 18
0
        public static ProductCategory_CE ToCE(ProductCategoryEntity item)
        {
            ProductCategory_CE target = new ProductCategory_CE();

            target.ID         = item.ID;
            target.CateNum    = item.CateNum;
            target.CateName   = item.CateName;
            target.IsDelete   = item.IsDelete;
            target.CreateTime = item.CreateTime;
            target.CreateUser = item.CreateUser;
            target.Remark     = item.Remark;
            return(target);
        }
Esempio n. 19
0
        /// <summary>
        /// 修改产品类别
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public int Update(ProductCategoryEntity entity)
        {
            entity.IncludeCateName(true).IncludeRemark(true)
            .Where(a => a.CateNum == entity.CateNum)
            ;
            int line = this.ProductCategory.Update(entity);

            if (line > 0)
            {
                CacheHelper.Remove(CacheKey.JOOSHOW_PRODUCTCATEGORY_CACHE);
            }
            return(line);
        }
Esempio n. 20
0
        /// <summary>
        /// 查询产品类别信息
        /// </summary>
        /// <returns></returns>
        public ActionResult Single()
        {
            string CompanyID = WebUtil.GetFormValue <string>("CompanyID");
            string SnNum     = WebUtil.GetFormValue <string>("SnNum");
            ProductCategoryProvider            provider = new ProductCategoryProvider(CompanyID);
            ProductCategoryEntity              entity   = provider.GetSingle(SnNum);
            DataResult <ProductCategoryEntity> result   = new DataResult <ProductCategoryEntity>()
            {
                Code = (int)EResponseCode.Success, Message = "响应成功", Result = entity
            };

            return(Content(JsonHelper.SerializeObject(result)));
        }
Esempio n. 21
0
        public ActionResult Add()
        {
            string cateNum = WebUtil.GetQueryStringValue <string>("cateNum", string.Empty);
            ProductCategoryEntity entity = null;

            if (!cateNum.IsEmpty())
            {
                ProductCategoryProvider provider = new ProductCategoryProvider();
                entity = provider.GetSingle(cateNum);
            }
            entity           = entity.IsNull() ? new ProductCategoryEntity() : entity;
            ViewBag.Category = entity;
            return(View());
        }
Esempio n. 22
0
        public IHttpActionResult DeleteProductCategoryEntity(string id)
        {
            ProductCategoryEntity productCategoryEntity = db.CategoryEntities.Find(id);

            if (productCategoryEntity == null)
            {
                return(NotFound());
            }

            db.CategoryEntities.Remove(productCategoryEntity);
            db.SaveChanges();

            return(Ok(productCategoryEntity));
        }
Esempio n. 23
0
        public async Task <int> Handle(CreateProductCategoryCommand request, CancellationToken cancellationToken)
        {
            //INSTEAD OF ProductCategoryEntity CREATE NEW DTO OBJECT
            var entity = new ProductCategoryEntity
            {
                Name = request.Name,
            };

            _context.ProductCategory.Add(entity);

            await _context.SaveChangesAsync(cancellationToken);

            return(entity.ProductCategoryId);
        }
        /// <summary>
        /// 修改产品类别
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public int Update(ProductCategoryEntity entity)
        {
            string Key = string.Format(CacheKey.JOOSHOW_PRODUCTCATEGORY_CACHE, this.CompanyID);

            entity.IncludeCateName(true).IncludeRemark(true)
            .Where(a => a.SnNum == entity.SnNum)
            ;
            int line = this.ProductCategory.Update(entity);

            if (line > 0)
            {
                CacheHelper.Remove(Key);
            }
            return(line);
        }
Esempio n. 25
0
        /// <summary>
        /// 根据产品类别删除删除
        /// </summary>
        /// <param name="cateNum"></param>
        /// <returns></returns>
        public int Delete(string cateNum)
        {
            ProductCategoryEntity entity = new ProductCategoryEntity();

            entity.Where(a => a.CateNum == cateNum);
            entity.IsDelete = (int)EIsDelete.Deleted;
            entity.IncludeIsDelete(true);
            int line = this.ProductCategory.Update(entity);

            if (line > 0)
            {
                CacheHelper.Remove(CacheKey.JOOSHOW_PRODUCTCATEGORY_CACHE);
            }
            return(line);
        }
Esempio n. 26
0
        public async Task <string> Handle(CreateProductCategoryCommand request, CancellationToken cancellationToken)
        {
            var entity = new ProductCategoryEntity
            {
                Id          = Guid.NewGuid().ToString(),
                Description = request.Description,
                Name        = request.Name
            };

            _relationalContext.Add(entity);

            await _relationalContext.SaveChangesAsync();

            return(entity.Id);
        }
Esempio n. 27
0
        public async Task <Unit> Handle(UpdateProductCategoryCommand request, CancellationToken cancellationToken)
        {
            var entity = new ProductCategoryEntity
            {
                Id          = request.Id,
                Description = request.Description,
                Name        = request.Name
            };

            _relationalContext.Update(entity);

            await _relationalContext.SaveChangesAsync();

            return(Unit.Value);
        }
Esempio n. 28
0
        private static void GetProCatInfo(System.Data.DataSet dataset, List <ProductEntity> list)
        {
            var rows = dataset.Tables[0].Rows;

            if (rows.Count > 2)
            {
                ProductCategoryProvider ProductCategory = new ProductCategoryProvider();
                for (var i = 2; i < rows.Count; i++)
                {
                    ProductEntity         entity   = new ProductEntity();
                    ProductCategoryEntity PCEntity = new ProductCategoryEntity();
                    var row = rows[i];
                    entity.SnNum = row[1].ToString();
                    if (string.IsNullOrEmpty(entity.SnNum))
                    {
                        continue;
                    }
                    entity.BarCode     = row[2].ToString();
                    entity.ProductName = row[3].ToString();
                    entity.CateName    = row[4].ToString();
                    PCEntity           = ProductCategory.GetSingleCateName(entity.CateName);
                    if (PCEntity.IsNotNull())
                    {
                        entity.CateNum = PCEntity.CateNum;
                    }
                    else
                    {
                        entity.CateNum = "";
                    }
                    entity.Num         = ConvertHelper.ToType <int>(row[5].ToString());
                    entity.MinNum      = ConvertHelper.ToType <int>(row[6].ToString());
                    entity.MaxNum      = ConvertHelper.ToType <int>(row[7].ToString());
                    entity.UnitName    = row[8].ToString();
                    entity.UnitNum     = entity.UnitNum;
                    entity.AvgPrice    = ConvertHelper.ToType <double>(row[9].ToString());
                    entity.InPrice     = ConvertHelper.ToType <double>(row[10].ToString());
                    entity.OutPrice    = ConvertHelper.ToType <double>(row[11].ToString());
                    entity.NetWeight   = ConvertHelper.ToType <double>(row[12].ToString());
                    entity.GrossWeight = ConvertHelper.ToType <double>(row[13].ToString());
                    entity.Remark      = row[14].ToString();

                    entity.IsDelete = (int)EIsDelete.NotDelete;

                    entity.CreateTime = DateTime.Now;
                    list.Add(entity);
                }
            }
        }
Esempio n. 29
0
        /// <summary>
        /// 根据类别名称查询类别信息
        /// </summary>
        /// <param name="cateName"></param>
        /// <returns></returns>
        public ProductCategory_CE GetSingleCateName(string cateName)
        {
            if (cateName.IsEmpty())
            {
                return(null);
            }
            ProductCategoryProvider provider = new ProductCategoryProvider();
            ProductCategoryEntity   entity   = provider.GetSingleCateName(cateName);

            if (entity.IsNotNull())
            {
                ProductCategory_CE ce = ProductCategory_To.ToCE(entity);
                return(ce);
            }
            return(null);
        }
Esempio n. 30
0
        public int Add(ProductModel model)
        {
            var newProduct = model.Adapt <ProductEntity>();

            if (model.BrandId.HasValue)
            {
                if (!brandRepository.FindById(model.BrandId.Value))
                {
                    throw new ValidatorException("Unkonwn brand");
                }
            }

            if (model.Categories.Count > 0)
            {
                var categoryIds = model.Categories
                                  .Select(x => x.CategoryId)
                                  .ToList();

                if (!categoryRepository.FindByIds(categoryIds))
                {
                    throw new ValidatorException("Unkonwn category");
                }

                var newProductCategories = new List <ProductCategoryEntity>();

                foreach (var category in model.Categories)
                {
                    var newProductCategory = new ProductCategoryEntity
                    {
                        ProductId  = newProduct.ProductId,
                        Product    = newProduct,
                        CategoryId = category.CategoryId
                    };

                    newProductCategories.Add(newProductCategory);
                }

                productCategoryRepository.AddCategories(newProductCategories);
            }

            productValidator.Validate(newProduct);

            productRepository.Add(newProduct);

            return(newProduct.ProductId);
        }
Esempio n. 31
0
		/// <summary>Po potrebi konvertira entity u business objekt.</summary>
		public static ProductCategory ConvertEntityToBusinessObject(ProductCategoryEntity entity)
		{
			ProductCategory bizobj = entity as ProductCategory;
			if (bizobj == null)
				bizobj = new ProductCategory(entity);

			return bizobj;
		}
Esempio n. 32
0
		/// <summary>Konvertira entitet u business object.</summary>
		protected ProductCategory(ProductCategoryEntity entity)
			: base(entity)
		{
		}