public async Task <int> SubmitAsync(int id, int userId) { var model = await GetIndexAsync(id); var list = await _storeInoutGoodsContext.GetListByStoreInoutAsync(id); var goods = list.Select(x => new StoreChangeGoodsValueModel { HospitalGoodId = x.HospitalGoods.Id, ChangeQty = x.Qty, Recrdno = RecordNumber.Next(model.ChangeType.Id, x.Id), }); using (var trans = _defaultDbTransaction.Begin()) { _storeContext.BatchCreateOrUpdate(new BatchStoreChangeApiModel { ChangeTypeId = model.ChangeType.Id, HospitalChangeGoods = goods.ToList(), }, model.HospitalDepartment.Id, userId); _StoreInoutRespository.UpdateStatus(id, StoreInoutStatus.Submited); trans.Commit(); } return(0); }
public async Task <int> SubmitAsync(int id) { using (var trans = _defaultDbTransaction.Begin()) { var bills = await _purchaseGoodsBillnoContext.GetListByPurchaseGoodsIdAsync(id); _purchaseGoodsBillnoContext.Submit(bills.Select(x => x.Id).ToList()); var result = _purchaseGoodsRespository.UpdateStatus(id, PurchaseGoodsStatus.Submited); trans.Commit(); return(result); } }
public async Task <int> BillAsync(int id, int userId) { var model = await _checkListRespository.GetIndexAsync(id); var list = await _checkListGoodsRespository.GetPreviewListAsync(id); using (var trans = _defaultDbTransaction.Begin()) { var goods1 = list.Where(x => x.StoreQty > x.CheckQty).Select(x => new StoreChangeGoodsValueModel { HospitalGoodId = x.HospitalGoods.Id, ChangeQty = x.StoreQty - x.CheckQty, Recrdno = RecordNumber.Next((int)StoreChangeType.CheckListOut, x.Id), }); _storeContext.BatchCreateOrUpdate(new BatchStoreChangeApiModel { ChangeTypeId = (int)StoreChangeType.CheckListOut, HospitalChangeGoods = goods1.ToList(), }, model.HospitalDepartment.Id, userId); var goods2 = list.Where(x => x.StoreQty < x.CheckQty).Select(x => new StoreChangeGoodsValueModel { HospitalGoodId = x.HospitalGoods.Id, ChangeQty = -x.StoreQty + x.CheckQty, Recrdno = RecordNumber.Next((int)StoreChangeType.CheckListIn, x.Id), }); _storeContext.BatchCreateOrUpdate(new BatchStoreChangeApiModel { ChangeTypeId = (int)StoreChangeType.CheckListIn, HospitalChangeGoods = goods2.ToList(), }, model.HospitalDepartment.Id, userId); _checkListRespository.UpdateStatus(id, CheckListStatus.Billed); trans.Commit(); } return(0); }