private SaleClaimCompensation GetSaleProductCompensationItem( SaleCompensationInfoItem model) { SaleClaimCompensationItem item = null; if (model != null && model.SaleProductItemId.HasValue)//.SaleContractId.HasValue && model.ProductItemId.HasValue) { item = db.SaleClaimCompensationItems.FirstOrDefault(m => m.SaleProductItemId == model.SaleProductItemId.GetValueOrDefault()); } if (item != null && item.SaleClaimCompensation != null) { return(item.SaleClaimCompensation); } //if (item != null && item.SaleProductItem != null // && item.SaleProductItem.SaleContract != null) //{ // SaleClaimCompensation claimCompensation = db.SaleClaimCompensations.Create(); // claimCompensation.IsCompensationClear = false; // claimCompensation.IsCompensationAbandoned = false; // return claimCompensation; //} return(null); // && (m.ProductItemId == model.ProductItemId.GetValueOrDefault())); //if (item == null) //{ // item = db.SaleProductItems.Create(); // item.ProductItemId = model.ProductItemId; // item.Quantity = model.Quantity; // item.SaleContractId = model.SaleContractId.GetValueOrDefault(); // item.StockItemId = model.StockItemId; // item.UnitPrice = model.UnitPrice; // item.Weight = model.Weight; // item.Currency = model.Currency; // item.Comments = model.Comments; //} //return item; }
public JsonResult ClaimCompensation(SaleCompensationInfoItem model) { if (model == null || model.SaleProductItemId.HasValue == false) { ModelState.AddModelError(string.Empty, "找不到请求索赔所对应的货品。"); return(Json(this.GetModelStateErrors(ModelState))); } SaleClaimCompensation entity = this.GetSaleProductCompensationItem(model); string errorMsg = AppBusinessManager.Instance.AddOrUpdateSaleClaimCompensation( HttpContext.GetOwinContext(), db, entity, model); if (!string.IsNullOrEmpty(errorMsg)) { ModelState.AddModelError(string.Empty, errorMsg); } return(Json(this.GetModelStateErrors(ModelState))); //FIXED 销售索赔业务逻辑 //return View(this.GetModelStateErrors(ModelState)); }