public object Post(ProductModel model)
        {
            if (model == null)
            {
                return Failed("产品不能为空");
            }
            if (string.IsNullOrEmpty(model.PartNumber))
            {
                return Failed("料号不能为空");
            }
            if (_productService.GetProducts().Any(n => n.PartNumber == model.PartNumber.Trim()))
            {

                return Failed("料号不能重复");
            }
            var item = new Product
            {
                Id = Guid.NewGuid(),
                PartNumber = model.PartNumber.Trim().ToUpper(),
                ProductType = string.IsNullOrEmpty(model.ProductType) ? model.ProductType : model.ProductType.Trim().ToUpper(),
                Voltage = string.IsNullOrEmpty(model.Voltage) ? model.Voltage : model.Voltage.Trim(),
                Capacity = string.IsNullOrEmpty(model.Capacity) ? model.Capacity : model.Capacity.Trim(),
                Pitch = string.IsNullOrEmpty(model.Pitch) ? model.Pitch : model.Pitch.Trim(),
                Level = string.IsNullOrEmpty(model.Level) ? model.Level : model.Level.Trim(),
                SpecificDesign =
                    string.IsNullOrEmpty(model.SpecificDesign) ? model.SpecificDesign : model.SpecificDesign.Trim(),
                Price = model.Price
            };
            try
            {
                _productService.Insert(item);
            }
            catch (Exception ex)
            {
                return Failed(ex.Message);
            }
            return Success();
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public object Get(string id)
        {
            if (!string.IsNullOrEmpty(id))
            {
                if (id.Trim().Length != 15)
                {
                    return Failed("未找到料号:" + id + "如果该料号是新料号,请确保是15位");
                }
                var productTypeComparisons = _comparisonService.GetProductTypeComparisons().ToArray();
                var voltageComparisons = _comparisonService.GetVoltageComparisons().ToArray();
                var levelComparisons = _comparisonService.GetLevelComparisons().ToArray();
                var pitchComparisons = _comparisonService.GetPitchComparisons().ToArray();
                var model = new ProductModel
                {
                    Id = Guid.NewGuid(),
                    PartNumber = id.Trim().ToUpper()
                };
                try
                {
                    model.Capacity = id.Substring(5, 3);
                }
                catch (Exception)
                {
                    // ignored
                }
                try
                {
                    var levelstr = id.Substring(8, 1).ToUpper();
                    model.Level =
                        levelComparisons.Where(n => n.Key == levelstr).Select(n => n.Value).FirstOrDefault();
                }
                catch (Exception)
                {
                    // ignored
                }
                try
                {
                    var typestr = id.Substring(0, 3).ToUpper();
                    model.ProductType =
                        productTypeComparisons.Where(n => n.Key == typestr).Select(n => n.Value).FirstOrDefault();
                }
                catch (Exception)
                {
                    // ignored
                }
                try
                {
                    var voltagestr = id.Substring(3, 2).ToUpper();
                    model.Voltage =
                        voltageComparisons.Where(n => n.Key == voltagestr).Select(n => n.Value).FirstOrDefault();
                }
                catch (Exception)
                {
                    // ignored
                }
                try
                {
                    var pitchstr = id.Substring(9, 1).ToUpper();
                    model.Pitch =
                        pitchComparisons.Where(n => n.Key == pitchstr).Select(n => n.Value).FirstOrDefault();
                }
                catch (Exception)
                {
                    // ignored
                }

                return model;
            }
            return Failed("找不到相关料号,请完善数据");
        }
        public object Put(ProductModel model)
        {
            var errormessage = string.Empty;
            if (model == null)
            {
                errormessage = "型号不能为空";
            }
            else if (string.IsNullOrEmpty(model.ProductType))
            {
                errormessage = "型号不能为空";
            }
            else if (string.IsNullOrEmpty(model.PartNumber))
            {
                errormessage = "料号不能为空";
            }
            else
            {
                var item = _productService.GetProduct(model.Id);
                if (item.IsDeleted)
                {
                    errormessage = "产品已删除";
                }
                if (string.IsNullOrEmpty(errormessage))
                {
                    item.PartNumber = model.PartNumber.Trim();
                    item.ProductType = model.ProductType.Trim();
                    item.Capacity = string.IsNullOrEmpty(model.Capacity) ? model.Capacity : model.Capacity.Trim();
                    item.Level = string.IsNullOrEmpty(model.Level) ? model.Level : model.Level.Trim();
                    item.ProductType = string.IsNullOrEmpty(model.ProductType) ? model.ProductType : model.ProductType.Trim();
                    item.Pitch = string.IsNullOrEmpty(model.Pitch) ? model.Pitch : model.Pitch.Trim();
                    item.Voltage = string.IsNullOrEmpty(model.Voltage) ? model.Voltage : model.Voltage.Trim();
                    item.SpecificDesign = string.IsNullOrEmpty(model.SpecificDesign) ? model.SpecificDesign : model.SpecificDesign.Trim();
                    item.Price = model.Price;
                    try
                    {
                        _productService.Update();
                    }
                    catch (Exception ex)
                    {
                        errormessage = ex.Message;
                    }
                }
            }
            return string.IsNullOrEmpty(errormessage) ? Success() : Failed(errormessage);

        }