Beispiel #1
0
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="brandEditVM"></param>
        /// <returns></returns>
        public ErrorCode Create(BrandEditVM brandEditVM)
        {
            try
            {
                if (BrandDal.GetExisted(o => o.CommodityTypeId == brandEditVM.CommodityTypeId && o.Name == brandEditVM.Name))
                {
                    return ErrorCode.BrandExisted;
                }

                var brand = new Brand
                {
                    Name = brandEditVM.Name,
                    CommodityTypeId = brandEditVM.CommodityTypeId,
                    Description = brandEditVM.Description,
                    CommodityId = brandEditVM.CommodityId
                };

                BrandDal.Create(brand);
                return ErrorCode.NoError;
            }
            catch (Exception)
            {
                return ErrorCode.ServerError;
            }
        }
Beispiel #2
0
        /// <summary>
        /// 编辑
        /// </summary>
        /// <param name="brandVM"></param>
        /// <returns></returns>
        public ErrorCode Update(BrandEditVM brandVM)
        {
            try
            {
                if (BrandDal.GetExisted(c => c.CommodityTypeId == brandVM.CommodityTypeId && c.Id != brandVM.Id && c.Name == brandVM.Name))
                {
                    return ErrorCode.BrandExisted;
                }

                var brand = new Brand
                {
                    Id = brandVM.Id,
                    Name = brandVM.Name,
                    CommodityId = brandVM.CommodityId,
                    CommodityTypeId = brandVM.CommodityTypeId,
                    Description = brandVM.Description
                };

                BrandDal.Update(brand);
                return ErrorCode.NoError;
            }
            catch (Exception)
            {
                return ErrorCode.ServerError;
            }
        }