/// <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)); } }
/// <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)); } }