/// <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 TangCaRepository(context); var entity = new Entity.MSSQL_QLDN_QLNS.Entity.TangCa(); entity.TangCaId = this.TangCaId; entity.NgayTangCa = this.NgayTangCa; entity.GioBatDau = this.GioBatDau; entity.GioKetThuc = this.GioKetThuc; entity.SoGio = this.SoGio == 0 ? 1 : this.SoGio; entity.Loai = this.Loai; entity.TieuDe = this.TieuDe == null ? "" : this.TieuDe; entity.LyDo = this.LyDo; entity.NhanVienId = this.NhanVienId; entity.MaTrangThai = this.MaTrangThai; entity.CtrVersion = _CtrVersion; entity = await repo.UpdatePartial(entity, nameof(Entity.MSSQL_QLDN_QLNS.Entity.TangCa.NgayTangCa), nameof(Entity.MSSQL_QLDN_QLNS.Entity.TangCa.GioBatDau), nameof(Entity.MSSQL_QLDN_QLNS.Entity.TangCa.GioKetThuc), nameof(Entity.MSSQL_QLDN_QLNS.Entity.TangCa.SoGio), nameof(Entity.MSSQL_QLDN_QLNS.Entity.TangCa.Loai), nameof(Entity.MSSQL_QLDN_QLNS.Entity.TangCa.TieuDe), nameof(Entity.MSSQL_QLDN_QLNS.Entity.TangCa.LyDo), nameof(Entity.MSSQL_QLDN_QLNS.Entity.TangCa.NhanVienId), nameof(Entity.MSSQL_QLDN_QLNS.Entity.TangCa.MaTrangThai), nameof(Entity.MSSQL_QLDN_QLNS.Entity.TangCa.CtrVersion) ); InsertLuocSuAction ls = new InsertLuocSuAction(); ls.InsertLuocSu(context, "TangCa", _Id, "Update", 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 TangCaRepository(context); var entity = new Entity.MSSQL_QLDN_QLNS.Entity.TangCa(); entity.NgayTangCa = this.NgayTangCa; entity.GioBatDau = this.GioBatDau; entity.GioKetThuc = this.GioKetThuc; entity.SoGio = this.SoGio; entity.Loai = this.Loai; entity.TieuDe = this.TieuDe == null? "" : this.TieuDe; entity.LyDo = this.LyDo; entity.NhanVienId = this.NhanVienId; entity.NguoiTao = this.NguoiTao == 0 ? 1 : this.NguoiTao; entity.NgayTao = DateTime.Now; entity.MaTrangThai = this.MaTrangThai; entity.XoaYN = "N"; entity.CtrVersion = 1; await repo.Insert(entity); if (entity.TangCaId == 0) { return(ActionHelper.returnActionError(HttpStatusCode.BadRequest, "Không thể thêm mới.")); } InsertLuocSuAction ls = new InsertLuocSuAction(); ls.InsertLuocSu(context, "TangCa", entity.TangCaId, "Insert", 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(); if (_listObj != null && _listObj.Count > 0) { var repo = new TangCaRepository(context); foreach (var obj in _listObj) { if (obj.ID > 0) { var objEntity = new Entity.MSSQL_QLDN_QLNS.Entity.TangCa(); objEntity.TangCaId = obj.ID; objEntity.CtrVersion = obj.CTRVERSION; objEntity.XoaYN = "Y"; objEntity = await repo.UpdatePartial(objEntity, nameof(Entity.MSSQL_QLDN_QLNS.Entity.TangCa.XoaYN) ); obj.XoaYN = objEntity.XoaYN; } } } 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)); } }