public void Insert(StandardCost StandardCost)
 {
     DbContext.StandardCosts.Add(StandardCost);
     Update();
 }
        public object Post(StandardCostModel model)
        {
            var errormessage = string.Empty;
            if (model == null)
            {
                errormessage = "报价不得为空";
            }
            else if (model.ProductModel == null || string.IsNullOrEmpty(model.ProductModel.PartNumber))
            {
                errormessage = "料号不能为空";
            }
            else if (model.QuotedTime == DateTime.MinValue)
            {
                errormessage = "报价日期不能为空";
            }
            else if (_standardCostService.GetStandardCosts().Any(n => n.Product.PartNumber == model.ProductModel.PartNumber && n.QuotedTime == model.QuotedTime))
            {
                errormessage = "报价不能重复";
            }

            if (string.IsNullOrEmpty(errormessage))
            {
                var product = _productService.GetProducts().FirstOrDefault(n => n.PartNumber == model.ProductModel.PartNumber);
                if (product == null || product.IsDeleted)
                {
                    errormessage = "找不到料号或料号被删除";
                }
                else
                {
                    var item = new StandardCost
                    {
                        Id = Guid.NewGuid(),
                        ProductId = product.Id,
                        Price = model.Price,
                        QuotedTime = model.QuotedTime,
                        Remark = model.Remark
                    };
                    try
                    {
                        _standardCostService.Insert(item);
                    }
                    catch (Exception ex)
                    {
                        return Failed(ex.Message);
                    }
                }
                
            }

            return string.IsNullOrEmpty(errormessage) ? Success() : Failed(errormessage);
        }