/// <summary>
        /// Ham xu ly chinh, chi nhan 1 bien moi truong
        /// </summary>
        /// <param name="context">Bien moi truong</param>
        /// <returns></returns>
        public async Task <ActionResultDto> Execute(ContextDto context)
        {
            try
            {
                Init();
                Validate();

                var repo = new KhoXuatNhapTonTheoKyRepository(context);

                var entity = new Entity.MSSQL_QLDN_QLNS.Entity.KhoBaoCaoTheoKy();
                entity.KyId        = this.KyId;
                entity.KyTruoc     = this.KyTruoc;
                entity.Ten         = this.Ten;
                entity.ThangNam    = this.ThangNam;
                entity.LoaiBaoCao  = this.LoaiBaoCao;
                entity.NgayBatDau  = this.NgayBatDau;
                entity.NgayKetThuc = this.NgayKetThuc;
                entity.KhoHangId   = this.KhoHangId;
                entity.GhiChu      = this.GhiChu;
                entity.NguoiTao    = this.NguoiTao;
                entity.MaTrangThai = this.MaTrangThai;

                entity = await repo.UpdatePartial(entity,
                                                  nameof(Entity.MSSQL_QLDN_QLNS.Entity.KhoBaoCaoTheoKy.KyTruoc),
                                                  nameof(Entity.MSSQL_QLDN_QLNS.Entity.KhoBaoCaoTheoKy.Ten),
                                                  nameof(Entity.MSSQL_QLDN_QLNS.Entity.KhoBaoCaoTheoKy.ThangNam),
                                                  nameof(Entity.MSSQL_QLDN_QLNS.Entity.KhoBaoCaoTheoKy.LoaiBaoCao),
                                                  nameof(Entity.MSSQL_QLDN_QLNS.Entity.KhoBaoCaoTheoKy.NgayBatDau),
                                                  nameof(Entity.MSSQL_QLDN_QLNS.Entity.KhoBaoCaoTheoKy.NgayKetThuc),
                                                  nameof(Entity.MSSQL_QLDN_QLNS.Entity.KhoBaoCaoTheoKy.KhoHangId),
                                                  nameof(Entity.MSSQL_QLDN_QLNS.Entity.KhoBaoCaoTheoKy.GhiChu),
                                                  nameof(Entity.MSSQL_QLDN_QLNS.Entity.KhoBaoCaoTheoKy.NguoiTao),
                                                  nameof(Entity.MSSQL_QLDN_QLNS.Entity.KhoBaoCaoTheoKy.MaTrangThai)
                                                  );

                InsertLuocSuAction ls = new InsertLuocSuAction();
                ls.InsertLuocSu(context, "KhoXuatNhapTonTheoKy", _Id, "Update", entity.NguoiTao);

                return(ActionHelper.returnActionResult(HttpStatusCode.OK, entity, null));
            }
            catch (FormatException ex)
            {
                return(ActionHelper.returnActionError(HttpStatusCode.BadRequest, ex.InnerException != null ? ex.InnerException.Message : ex.Message));
            }
            catch (Exception ex)
            {
                return(ActionHelper.returnActionError(HttpStatusCode.InternalServerError, ex.InnerException != null ? ex.InnerException.Message : ex.Message));
            }
        }
Esempio n. 2
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 <ActionResultDto> Execute(ContextDto context)
        {
            try
            {
                init();
                validate();

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

                    foreach (var obj in _listObj)
                    {
                        if (obj.ID > 0)
                        {
                            //var objEntity = new Entity.MSSQL_QLDN_QLNS.Entity.KhoBaoCaoTheoKy();
                            //objEntity.KyId = obj.ID;

                            //objEntity.XoaYN = "Y";

                            //objEntity = await repo.UpdatePartial(objEntity,
                            //    nameof(Entity.MSSQL_QLDN_QLNS.Entity.KhoBaoCaoTheoKy.XoaYN)
                            //    );

                            //obj.XoaYN = objEntity.XoaYN;

                            var biz = new DeleteKhoKyChiTietByKyIdBiz(context);
                            biz.KyId = obj.ID;
                            var result = await biz.Execute();

                            dynamic _metaData = new System.Dynamic.ExpandoObject();

                            return(ActionHelper.returnActionResult(HttpStatusCode.OK, _listObj, null));
                        }
                    }
                }

                return(ActionHelper.returnActionResult(HttpStatusCode.OK, _listObj, null));
            }
            catch (FormatException ex)
            {
                return(ActionHelper.returnActionError(HttpStatusCode.BadRequest, ex.InnerException != null ? ex.InnerException.Message : ex.Message));
            }
            catch (Exception ex)
            {
                return(ActionHelper.returnActionError(HttpStatusCode.InternalServerError, ex.InnerException != null ? ex.InnerException.Message : ex.Message));
            }
        }
Esempio n. 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 <ActionResultDto> Execute(ContextDto context)
        {
            try
            {
                Init();
                Validate();

                var repo = new KhoXuatNhapTonTheoKyRepository(context);

                var entity = new Entity.MSSQL_QLDN_QLNS.Entity.KhoBaoCaoTheoKy();
                entity.KyTruoc     = this.KyTruoc;
                entity.Ten         = this.Ten;
                entity.ThangNam    = this.ThangNam;
                entity.KhoHangId   = this.KhoHangId;
                entity.NgayBatDau  = this.NgayBatDau;
                entity.NgayKetThuc = this.NgayKetThuc;
                entity.LoaiBaoCao  = this.LoaiBaoCao;
                entity.GhiChu      = this.GhiChu;
                entity.NgayTao     = DateTime.Now;
                entity.XoaYN       = "N";
                entity.CtrlVersion = 1;
                entity.NguoiTao    = this.NguoiTao;
                entity.MaTrangThai = this.MaTrangThai;

                await repo.Insert(entity);

                if (entity.KyId == 0)
                {
                    return(ActionHelper.returnActionError(HttpStatusCode.BadRequest, "Không thể thêm mới."));
                }

                InsertLuocSuAction ls = new InsertLuocSuAction();
                ls.InsertLuocSu(context, "KhoBaoCaoTheoKy", entity.KyId, "Insert", entity.NguoiTao);

                return(ActionHelper.returnActionResult(HttpStatusCode.OK, entity, null));
            }
            catch (FormatException ex)
            {
                return(ActionHelper.returnActionError(HttpStatusCode.BadRequest, ex.InnerException != null ? ex.InnerException.Message : ex.Message));
            }
            catch (Exception ex)
            {
                return(ActionHelper.returnActionError(HttpStatusCode.InternalServerError, ex.InnerException != null ? ex.InnerException.Message : ex.Message));
            }
        }