public async Task <dynamic> Execute(ContextDto context) { try { init(); validate(); var repo = new KhoPhieuChiRepository(context); if (_KhoPhieuChi != null) { var congviecEntity = new Entity.MSSQL_QLDN_QLNS.Entity.KhoPhieuChi(); congviecEntity.PhieuChiId = _KhoPhieuChi.PhieuChiId; congviecEntity.XoaYN = "Y"; congviecEntity.SoPhieu = null; congviecEntity = await repo.UpdatePartial(congviecEntity, nameof(Entity.MSSQL_QLDN_QLNS.Entity.KhoPhieuChi.XoaYN), nameof(Entity.MSSQL_QLDN_QLNS.Entity.KhoPhieuChi.SoPhieu) ); _KhoPhieuChi.XoaYN = congviecEntity.XoaYN; InsertKhoLuocSuAction ls = new InsertKhoLuocSuAction(); ls.InsertKhoLuocSu(context, "KhoPhieuChi", congviecEntity.PhieuChiId, "Delete", 0); } else { if (_listKhoPhieuChi != null && _listKhoPhieuChi.Count > 0) { foreach (var congviecModel in _listKhoPhieuChi) { if (congviecModel.PhieuChiId > 0) { var congviecEntity = new Entity.MSSQL_QLDN_QLNS.Entity.KhoPhieuChi(); congviecEntity.PhieuChiId = congviecModel.PhieuChiId; congviecEntity.XoaYN = "Y"; congviecEntity.SoPhieu = ""; congviecEntity = await repo.UpdatePartial(congviecEntity, nameof(Entity.MSSQL_QLDN_QLNS.Entity.KhoPhieuChi.XoaYN), nameof(Entity.MSSQL_QLDN_QLNS.Entity.KhoPhieuChi.SoPhieu) ); congviecModel.XoaYN = congviecEntity.XoaYN; InsertKhoLuocSuAction ls = new InsertKhoLuocSuAction(); ls.InsertKhoLuocSu(context, "KhoPhieuChi", congviecEntity.PhieuChiId, "Delete", 0); } } } } return(ActionHelper.returnActionResult(HttpStatusCode.OK, _listKhoPhieuChi, null)); } catch (FormatException ex) { return(ActionHelper.returnActionError(HttpStatusCode.BadRequest, ex.Message)); } catch (Exception ex) { return(ActionHelper.returnActionError(HttpStatusCode.InternalServerError, ex.Message)); } }
public async Task <ActionResultDto> Execute(ContextDto context) { try { validate(); var PhieuChi = new Entity.MSSQL_QLDN_QLNS.Entity.KhoPhieuChi(); PhieuChi.SoPhieu = SoPhieu; PhieuChi.KhachHangId = KhachHangId; PhieuChi.LyDo = LyDo; PhieuChi.NgayChi = NgayChi; PhieuChi.SoTien = SoTien; PhieuChi.SoTienBangChu = SoTienBangChu; PhieuChi.HinhThucThanhToan = HinhThucThanhToan; PhieuChi.NganHang = NganHang; PhieuChi.TaiKhoanCo = TaiKhoanCo; PhieuChi.TaiKhoanNo = TaiKhoanNo; PhieuChi.Hinh = Hinh; PhieuChi.GhiChu = GhiChu; PhieuChi.Hinh = Hinh; PhieuChi.NguoiNhanTien = NguoiNhanTien; PhieuChi.NguoiTao = NguoiTao; PhieuChi.NgayTao = DateTime.Now; PhieuChi.XoaYN = "N"; PhieuChi.CtrVersion = 1; KhoPhieuChiRepository repo = new KhoPhieuChiRepository(context); await repo.Insert(PhieuChi); InsertKhoLuocSuAction ls = new InsertKhoLuocSuAction(); ls.InsertKhoLuocSu(context, "KhoPhieuChi", PhieuChi.PhieuChiId, "Insert", int.Parse(PhieuChi.NguoiTao.ToString())); return(returnActionResult(HttpStatusCode.OK, PhieuChi, null)); } catch (FormatException ex) { return(returnActionError(HttpStatusCode.BadRequest, ex.InnerException != null ? ex.InnerException.Message : ex.Message)); } catch (Exception ex) { return(returnActionError(HttpStatusCode.InternalServerError, ex.InnerException != null ? ex.InnerException.Message : ex.Message)); } }