public async Task <ActionResultDto> Execute(ContextDto context) { try { init(); validate(); var biz = new GetListChiTietByPhieuNhapIdBiz(context); biz.PHIEU_NHAP_ID = _phieuNhapId; biz.LOGIN_ID = _LoginId; var result = await biz.Execute(); dynamic _metaData = new System.Dynamic.ExpandoObject(); return(ActionHelper.returnActionResult(HttpStatusCode.OK, result, _metaData)); } catch (BaseException ex) { return(ActionHelper.returnActionError(HttpStatusCode.BadRequest, ex.Message)); } catch (Exception ex) { return(ActionHelper.returnActionError(HttpStatusCode.InternalServerError, ex.InnerException != null ? ex.InnerException.Message : ex.Message)); } }
public async Task <ActionResultDto> Execute(ContextDto context) { try { init(); validate(); // TODO load chi tiêt var bizGetListChiTiet = new GetListChiTietByPhieuNhapIdBiz(context); bizGetListChiTiet.PHIEU_NHAP_ID = _phieuNhapId; bizGetListChiTiet.LOGIN_ID = _LoginId; var listChiTiet = await bizGetListChiTiet.Execute(); if (listChiTiet.Count() < 1) { throw new BaseException("Không tìm thấy thông tin chi tết"); } var affected = 0; var biz = new LuuSoCaiBiz(context); foreach (var chitiet in listChiTiet) { biz.PHIEU_NHAP_CHI_TIET_ID = chitiet.PhieuNhapChiTietId; var result = await biz.Execute(); if (result.Count() > 0 && string.IsNullOrEmpty(biz.MESSAGE)) { affected = affected + 1; } else { throw new BaseException(biz.MESSAGE.Split('|')[2]); } } // TODO đổi trang thai phiếu nhập var repoPhieuNhap = new KhoPhieuNhapRepository(context); var phieunhap = new Entity.MSSQL_QLDN_QLNS.Entity.KhoPhieuNhap(); phieunhap.PhieuNhapId = _phieuNhapId; phieunhap.MaTrangThai = "KPN_LSC"; var resultUpdatePhieuNhap = await repoPhieuNhap.UpdatePartial(phieunhap , nameof(phieunhap.MaTrangThai)); var ls = new InsertKhoLuocSuAction(); ls.InsertKhoLuocSu(context, "KhoPhieuNhap", _phieuNhapId, "Update", _LoginId); dynamic _metaData = new System.Dynamic.ExpandoObject(); return(ActionHelper.returnActionResult(HttpStatusCode.OK, resultUpdatePhieuNhap, _metaData)); } catch (BaseException ex) { return(ActionHelper.returnActionError(HttpStatusCode.BadRequest, ex.Message)); } catch (Exception ex) { return(ActionHelper.returnActionError(HttpStatusCode.InternalServerError, ex.InnerException != null ? ex.InnerException.Message : ex.Message)); } }