/// <summary> /// 增加一个销售的记录表 /// </summary> /// <param name="sale"></param> /// <returns></returns> public async Task <bool> AddSale(Sale sale) { if (sale != null) { var product = await _productRepository.GetModelAsync(u => u.Id == sale.ProductId && u.Quantity >= sale.Quantity); if (product != null) { var model = await _saleRepository.AddModel(sale); if (model > 0) { product.Quantity -= sale.Quantity; var flag = await _productRepository.Modify(product); if (flag > 1) { return(true); } } } } return(false); }