public async Task <ActionResultDto> Execute(ContextDto context) { try { var duan = new Entity.MSSQL_QLDN_QLNS.Entity.DuAn(); duan.TenDuAn = TenDuAn; duan.MoTa = MoTa; duan.MaTrangThai = MaTrangThai; duan.PhongBan = Protector.Int(PhongBan); duan.QuanLy = Protector.Int(QuanLy); if (NgayBatDau != "" && NgayBatDau != null) { duan.NgayBatDau = DateTime.ParseExact(NgayBatDau, "dd/MM/yyyy", CultureInfo.GetCultureInfo("fr-FR")); } if (NgayThatSuBatDau != null && NgayThatSuBatDau != "") { duan.NgayThatSuBatDau = DateTime.ParseExact(NgayThatSuBatDau, "dd/MM/yyyy", CultureInfo.GetCultureInfo("fr-FR")); } if (NgayKetThuc != null && NgayKetThuc != "") { duan.NgayKetThuc = DateTime.ParseExact(NgayKetThuc, "dd/MM/yyyy", CultureInfo.GetCultureInfo("fr-FR")); } if (NgayThatSuKetThuc != null && NgayThatSuKetThuc != "") { duan.NgayThatSuKetThuc = DateTime.ParseExact(NgayThatSuKetThuc, "dd/MM/yyyy", CultureInfo.GetCultureInfo("fr-FR")); } duan.NguoiTao = Protector.Int(NguoiTao); duan.NgayTao = DateTime.Now; duan.XoaYN = "N"; duan.CtrVersion = 1; DuAnRepository repo = new DuAnRepository(context); await repo.Insert(duan); InsertLuocSuAction ls = new InsertLuocSuAction(); ls.InsertLuocSu(context, "DuAn", duan.DuAnId, "Insert", duan.NguoiTao); if (NhanVien != "" && NhanVien != null) { var nvda = new Entity.MSSQL_QLDN_QLNS.Entity.NhanVienDuAn(); var nvids = NhanVien.Split('|'); foreach (var nv in nvids) { nvda.DuAnId = duan.DuAnId; nvda.XoaYN = "N"; nvda.NhanVienId = Protector.Int(nv); await repo.InsertNV(nvda); } } return(returnActionResult(HttpStatusCode.OK, duan, null)); } catch (FormatException ex) { return(returnActionError(HttpStatusCode.BadRequest, ex.InnerException != null ? ex.InnerException.Message : ex.Message)); } catch (Exception ex) { return(returnActionError(HttpStatusCode.InternalServerError, ex.InnerException != null ? ex.InnerException.Message : ex.Message)); } }
public async Task <dynamic> Execute(ContextDto context) { try { dynamic result = new System.Dynamic.ExpandoObject(); var repo = new DuAnRepository(context); await repo.UpdatePartial(this, nameof(TenDuAn), nameof(MoTa), nameof(MaTrangThai), nameof(PhongBan), nameof(QuanLy), nameof(NgayBatDau), nameof(NgayThatSuBatDau), nameof(NgayKetThuc), nameof(CtrVersion), nameof(NgayThatSuKetThuc) ); result.data = this; InsertLuocSuAction ls = new InsertLuocSuAction(); ls.InsertLuocSu(context, "DuAn", DuAnId, "Update", NguoiTao); Data.QLNS.DuAn.DeleteOneNhanVienDuAnDac dac = new Data.QLNS.DuAn.DeleteOneNhanVienDuAnDac(context); dac.DuAnId = DuAnId.ToString(); await dac.Execute(); if (NhanVien != null && NhanVien != "") { var nvda = new Entity.MSSQL_QLDN_QLNS.Entity.NhanVienDuAn(); var nvids = NhanVien.Split('|'); foreach (var nv in nvids) { nvda.DuAnId = DuAnId; nvda.XoaYN = "N"; nvda.NhanVienId = Protector.Int(nv); await repo.InsertNV(nvda); } } return(returnActionResult(this, null)); } catch (FormatException ex) { return(returnActionError(HttpStatusCode.BadRequest, ex.Message)); } catch (Exception ex) { return(returnActionError(HttpStatusCode.InternalServerError, ex.Message)); } }