Exemple #1
0
        /// <summary>
        /// Ham xu ly chinh, chi nhan 1 bien moi truong
        /// </summary>
        /// <param name="context">Bien moi truong</param>
        /// <returns></returns>
        public async Task <Entity.MSSQL_QLDN_QLNS.Entity.PhieuCongTacChiTiet> Execute()
        {
            Init();
            Validate();

            var obj = createObj();

            var repo   = new PhieuCongTacChiTietRepository(_context);
            var result = await repo.Insert(obj);

            return(result);
        }
Exemple #2
0
        public async Task <dynamic> Execute(ContextDto context)
        {
            try
            {
                init();
                validate();

                if (_list != null && _list.Count > 0)
                {
                    var repo = new PhieuCongTacChiTietRepository(context);

                    foreach (var model in _list)
                    {
                        if (model.PhieuCongTacChiTietId > 0)
                        {
                            var entity = new Entity.MSSQL_QLDN_QLNS.Entity.PhieuCongTacChiTiet();
                            entity.PhieuCongTacChiTietId = model.PhieuCongTacChiTietId;
                            entity.CtrVersion            = model.CtrVersion;

                            entity.XoaYN = "Y";

                            entity = await repo.UpdatePartial(entity,
                                                              nameof(Entity.MSSQL_QLDN_QLNS.Entity.PhieuCongTacChiTiet.XoaYN)
                                                              );

                            model.XoaYN = entity.XoaYN;
                        }
                    }
                }

                return(ActionHelper.returnActionResult(HttpStatusCode.OK, _list, null));
            }
            catch (FormatException ex)
            {
                return(ActionHelper.returnActionError(HttpStatusCode.BadRequest, ex.Message));
            }
            catch (Exception ex)
            {
                return(ActionHelper.returnActionError(HttpStatusCode.InternalServerError, ex.Message));
            }
        }
Exemple #3
0
        /// <summary>
        /// Ham xu ly chinh, chi nhan 1 bien moi truong
        /// </summary>
        /// <param name="context">Bien moi truong</param>
        /// <returns></returns>
        public async Task <Entity.MSSQL_QLDN_QLNS.Entity.PhieuCongTacChiTiet> Execute()
        {
            Init();
            Validate();

            var obj = createObj();

            // TODO kiểm tra trạng thái duyệt của phiếu công tác
            var phieuCongtacDac = new GetPhieuCongTacByChiTietIdDac(_context);

            phieuCongtacDac.CHI_TIET_ID = PhieuCongTacChiTietId;

            var resultCheck = await phieuCongtacDac.Execute() as List <GetPhieuCongTacByChiTietIdDto>;

            /* trường hợp không tìm thấy phiếu công tác, chưa nghỉ ra cách xử lý
             * tạm throw exception
             */
            if (resultCheck == null || resultCheck.Count == 0)
            {
                throw new BaseException("Phiếu chi tiết này không thuộc về phiếu công tác nào.");
            }

            if (resultCheck[0].MaTrangThai == "PCT_DY" || resultCheck[0].MaTrangThai == "PCT_TC")
            {
                throw new BaseException("Không thể thây đổi thông tin phiếu đã được duyệt.");
            }

            var repo   = new PhieuCongTacChiTietRepository(_context);
            var result = await repo.UpdatePartial(obj
                                                  , nameof(Entity.MSSQL_QLDN_QLNS.Entity.PhieuCongTacChiTiet.Ngay)
                                                  , nameof(Entity.MSSQL_QLDN_QLNS.Entity.PhieuCongTacChiTiet.NoiDung)
                                                  , nameof(Entity.MSSQL_QLDN_QLNS.Entity.PhieuCongTacChiTiet.SoLuong)
                                                  , nameof(Entity.MSSQL_QLDN_QLNS.Entity.PhieuCongTacChiTiet.DonGia)
                                                  , nameof(Entity.MSSQL_QLDN_QLNS.Entity.PhieuCongTacChiTiet.GhiChu)
                                                  );

            return(result);
        }