public async Task <int> ComfirmAsync(IList <int> ids, int userId) { foreach (var id in ids) { var goods = await _purchaseGoodsBillnoRespository.GetIndexAsync(id); var changed = new StoreChangeApiModel { ChangeTypeId = (int)StoreChangeType.Purchase, HospitalChangeGoods = new StoreChangeGoodsValueModel { HospitalGoodId = goods.HospitalGoods.Id, ChangeQty = goods.Qty, Recrdno = RecordNumber.Next((int)StoreChangeType.Purchase, id), }, }; var recordId = _storeContext.CreateOrUpdate(changed, goods.Purchase.HospitalDepartment.Id, userId); _storeRecordBillnoContext.Create(id, recordId); _purchaseGoodsBillnoRespository.UpdateStatus(id, BillStatus.Comfirmed); } return(ids.Count); }