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));
            }
        }
Example #2
0
        public async Task <dynamic> Execute(ContextDto context)
        {
            try
            {
                dynamic result = new ActionResultDto();

                var repo = new KhoPhieuChiRepository(context);
                await repo.UpdatePartial(this,
                                         nameof(SoPhieu),
                                         nameof(KhachHangId),
                                         nameof(NgayChi),
                                         nameof(LyDo),
                                         nameof(SoTien),
                                         nameof(SoTienBangChu),
                                         nameof(HinhThucThanhToan),
                                         nameof(NganHang),
                                         nameof(TaiKhoanCo),
                                         nameof(TaiKhoanNo),
                                         nameof(Hinh),
                                         nameof(GhiChu),
                                         nameof(Hinh),
                                         nameof(NguoiNhanTien)
                                         );

                result.ReturnCode = HttpStatusCode.OK;
                result.ReturnData = new
                {
                    data = this
                };
                InsertKhoLuocSuAction ls = new InsertKhoLuocSuAction();
                ls.InsertKhoLuocSu(context, "KhoPhieuChi", PhieuChiId, "Update", int.Parse(NguoiTao.ToString()));
                return(result);
            }
            catch (FormatException ex)
            {
                return(returnActionError(HttpStatusCode.BadRequest, ex.Message));
            }
            catch (Exception ex)
            {
                return(returnActionError(HttpStatusCode.InternalServerError, ex.Message));
            }
        }