/// <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 count = 0; var repo = new NghiPhepRepository(context); for (int i = 0; i < _listId.Count; i++) { if (_listId[i] > 0 && await repo.Delete(_listId[i])) { InsertLuocSuAction ls = new InsertLuocSuAction(); ls.InsertLuocSu(context, "NghiPhep", _listId[i], "Delete", 0); count++; } } return(ActionHelper.returnActionResult(HttpStatusCode.OK, count, 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 NghiPhepRepository(context); var nghiphep = await repo.GetById(_id); if (nghiphep == null) { return(ActionHelper.returnActionError(HttpStatusCode.BadRequest, string.Format("Không tìm thấy NghiPhepId '{0}'", _id))); } return(ActionHelper.returnActionResult(HttpStatusCode.OK, nghiphep, 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 NghiPhepRepository(context); var nghiphep = new Entity.MSSQL_QLDN_QLNS.Entity.NghiPhep(); nghiphep.NghiPhepId = _nghiphepId; nghiphep.TuNgay = this.TuNgay == null ? DateTime.Today : this.TuNgay; nghiphep.DenNgay = this.DenNgay == null ? DateTime.Today : this.DenNgay; nghiphep.SoNgay = this.SoNgay == 0 ? 1 : this.SoNgay; nghiphep.LoaiNgay = this.LoaiNgay; nghiphep.MaLoaiNghiPhep = this.MaLoaiNghiPhep; nghiphep.TieuDe = this.TieuDe == null ? "" : this.TieuDe; nghiphep.LyDo = this.LyDo; nghiphep.NguoiBanGiao = this.NguoiBanGiao; nghiphep.NhanVienId = this.NhanVienId; nghiphep.CtrVersion = _CtrVersion; nghiphep = await repo.UpdatePartial(nghiphep, nameof(Entity.MSSQL_QLDN_QLNS.Entity.NghiPhep.TuNgay), nameof(Entity.MSSQL_QLDN_QLNS.Entity.NghiPhep.DenNgay), nameof(Entity.MSSQL_QLDN_QLNS.Entity.NghiPhep.SoNgay), nameof(Entity.MSSQL_QLDN_QLNS.Entity.NghiPhep.LoaiNgay), nameof(Entity.MSSQL_QLDN_QLNS.Entity.NghiPhep.MaLoaiNghiPhep), nameof(Entity.MSSQL_QLDN_QLNS.Entity.NghiPhep.TieuDe), nameof(Entity.MSSQL_QLDN_QLNS.Entity.NghiPhep.LyDo), nameof(Entity.MSSQL_QLDN_QLNS.Entity.NghiPhep.NguoiBanGiao), nameof(Entity.MSSQL_QLDN_QLNS.Entity.NghiPhep.NhanVienId), nameof(Entity.MSSQL_QLDN_QLNS.Entity.NghiPhep.CtrVersion) ); InsertLuocSuAction ls = new InsertLuocSuAction(); ls.InsertLuocSu(context, "NghiPhep", _nghiphepId, "Update", NhanVienId); return(ActionHelper.returnActionResult(HttpStatusCode.OK, nghiphep, 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 NghiPhepRepository(context); var nghiphep = new Entity.MSSQL_QLDN_QLNS.Entity.NghiPhep(); nghiphep.TuNgay = this.TuNgay; nghiphep.DenNgay = this.DenNgay; nghiphep.SoNgay = this.SoNgay; nghiphep.LoaiNgay = this.LoaiNgay; nghiphep.TieuDe = this.TieuDe == null? "" : this.TieuDe; nghiphep.LyDo = this.LyDo; nghiphep.NguoiBanGiao = this.NguoiBanGiao; nghiphep.NhanVienId = this.NhanVienId; nghiphep.NguoiTao = this.NguoiTao == 0 ? 1 : this.NguoiTao; nghiphep.NgayTao = DateTime.Now; nghiphep.MaTrangThai = this.MaTrangThai; nghiphep.MaLoaiNghiPhep = this.MaLoaiNghiPhep; nghiphep.XoaYN = "N"; nghiphep.CtrVersion = 1; await repo.Insert(nghiphep); if (nghiphep.NghiPhepId == 0) { return(ActionHelper.returnActionError(HttpStatusCode.BadRequest, "Không thể thêm Nghỉ phép.")); } InsertLuocSuAction ls = new InsertLuocSuAction(); ls.InsertLuocSu(context, "NghiPhep", nghiphep.NghiPhepId, "Insert", NguoiTao); return(ActionHelper.returnActionResult(HttpStatusCode.OK, nghiphep, 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)); } }
public async Task <dynamic> Execute(ContextDto context) { try { init(); validate(); if (_listObj != null && _listObj.Count > 0) { var repo = new NghiPhepRepository(context); foreach (var obj in _listObj) { if (obj.NP_ID > 0) { var objEntity = new Entity.MSSQL_QLDN_QLNS.Entity.NghiPhep(); objEntity.NghiPhepId = obj.NP_ID; objEntity.CtrVersion = obj.CTRVERSION; objEntity.XoaYN = "Y"; objEntity = await repo.UpdatePartial(objEntity, nameof(Entity.MSSQL_QLDN_QLNS.Entity.NghiPhep.XoaYN) ); obj.XoaYN = objEntity.XoaYN; } } } return(ActionHelper.returnActionResult(HttpStatusCode.OK, _listObj, null)); } catch (FormatException ex) { return(ActionHelper.returnActionError(HttpStatusCode.BadRequest, ex.Message)); } catch (Exception ex) { return(ActionHelper.returnActionError(HttpStatusCode.InternalServerError, ex.Message)); } }