public ImportCouponDetail AddImportCouponDetail(ImportCouponDetail importCouponDetail) { _unitOfWork.GetRepositoryInstance <ImportCouponDetail>().Add(importCouponDetail); //Update total amount ImportCoupon importCoupon = _unitOfWork.GetRepositoryInstance <ImportCoupon>().GetFirstorDefault(importCouponDetail.importCouponID.Value); Supplier supplier = _unitOfWork.GetRepositoryInstance <Supplier>().GetFirstorDefault(importCoupon.supplierID.Value); supplier.totalAmount += importCouponDetail.price * importCouponDetail.quantity; _unitOfWork.GetRepositoryInstance <Supplier>().Update(supplier); return(importCouponDetail); }
public void InsertImportCouponDetail(eImportCouponDetail imde) { ImportCouponDetail i = new ImportCouponDetail(); i.impdetaiID = imde.ImpdetailID; i.quantity = imde.Quantity; i.price = (decimal)imde.Price; i.total = (decimal)imde.Total; i.impID = imde.ImpID; db.ImportCouponDetails.InsertOnSubmit(i); db.SubmitChanges(); }