private void AddOrUpdateVanBan(int id, EditCongViecViewModel model) { var vanbanUpdate = model.VanBanLienQuanViewModel?.Where(x => x.Id > 0); if (vanbanUpdate != null && vanbanUpdate.Any()) { CongViecVanBanRepository.UpdateRange(vanbanUpdate.Select(x => new CongViecVanBanResult { Id = x.Id, HoSoCongViecId = id, SoVanBan = x.SoVanBan, NgayBanHanh = x.NgayBanHanh, NoiDung = x.NoiDung, CoQuanId = x.CoQuanId, LastUpdatedBy = UserName, IsDeleted = false })); } var vanBanAdd = model.VanBanLienQuanViewModel?.Where(x => x.Id == 0); if (vanBanAdd != null && vanBanAdd.Any()) { CongViecVanBanRepository.AddRange(vanbanUpdate.Select(x => new CongViecVanBanResult { HoSoCongViecId = id, SoVanBan = x.SoVanBan, NgayBanHanh = x.NgayBanHanh, NoiDung = x.NoiDung, CoQuanId = x.CoQuanId, CreatedBy = UserName, IsDeleted = false })); } }
public ActionResult Detail(int id) { var hoso = HoSoCongViecRepository.Single(id); var init = InitModel(); var coQuanInfos = CoQuanRepository.GetAll().Select(x => x.ToDataInfo()); var model = new EditCongViecViewModel { Id = id, UsersInfos = init.UsersInfos, LinhVucCongViecInfos = init.LinhVucCongViecInfos, TrangThaiCongViecInfos = init.TrangThaiCongViecInfos, CoQuanInfos = coQuanInfos, LinhVucCongViecId = hoso.LinhVucCongViecId, VanBanLienQuanViewModel = hoso.CongViecVanBanResults.ToList(), QuaTrinhXuLyViewModel = hoso.CongViecQuaTrinhXuLyResult.ToList(), NgayHetHan = hoso.NgayHetHan, NgayKhoiTao = hoso.NgayTao, NoiDungCongViec = hoso.NoiDung, TrangThaiCongViecId = hoso.TrangThaiCongViecId, UserPhuTrachId = hoso.UserPhuTrachId, UserXuLyChinhId = hoso.UserXuLyId, UsersPhoiHopId = hoso.CongViecPhoiHopResult.Select(x => x.UserId).ToArray(), DanhGiaCongViec = hoso.DanhGiaCongViec.HasValue ? (EnumDanhGiaCongViec)hoso.DanhGiaCongViec.Value : EnumDanhGiaCongViec.LEVEL0, JsonFiles = GetPathFiles(EnsureFolderCongViec(id)) }; return(View(model)); }
private void AddOrUpdateXuLy(int id, EditCongViecViewModel model) { var quaTrinhUpdate = model.QuaTrinhXuLyViewModel?.Where(x => x.Id > 0); if (quaTrinhUpdate != null && quaTrinhUpdate.Any()) { QuaTrinhXuLyRepository.UpdateRange(quaTrinhUpdate.Select(x => new CongViecQuaTrinhXuLyResult { Id = x.Id, HoSoCongViecId = model.Id, GioBanHanh = x.GioBanHanh, PhutBanHanh = x.PhutBanHanh, NgayBanHanh = x.NgayBanHanh, NoiDung = x.NoiDung, NguoiThem = x.NguoiThem, NhacNho = x.NhacNho, IsDeleted = false, LastUpdatedBy = UserName })); } var quaTrinhAdd = model.QuaTrinhXuLyViewModel?.Where(x => x.Id == 0); if (quaTrinhAdd != null && quaTrinhAdd.Any()) { QuaTrinhXuLyRepository.AddRange(quaTrinhAdd.Select(x => new CongViecQuaTrinhXuLyResult { HoSoCongViecId = model.Id, GioBanHanh = x.GioBanHanh, PhutBanHanh = x.PhutBanHanh, NgayBanHanh = x.NgayBanHanh, NoiDung = x.NoiDung, NguoiThem = x.NguoiThem, NhacNho = x.NhacNho, IsDeleted = false, CreatedBy = UserName })); } }
public JsonResult Detail(int id, EditCongViecViewModel model) { return(ExecuteWithErrorHandling(() => { var congViec = HoSoCongViecRepository.Single(id); //Get all van ban lien quan AddOrUpdateXuLy(id, model); AddOrUpdateVanBan(id, model); if (User.IsInRole(RoleConstant.LANHDAO)) { congViec.NgayHetHan = model.NgayHetHan; congViec.LinhVucCongViecId = model.LinhVucCongViecId; congViec.UserPhuTrachId = model.UserPhuTrachId; congViec.DanhGiaCongViec = model.DanhGiaCongViec == EnumDanhGiaCongViec.LEVEL0 ? null : (byte?)model.DanhGiaCongViec; congViec.UserXuLyId = model.UserXuLyChinhId; congViec.CongViecPhoiHopResult = model.UsersPhoiHopId?.Select(x => new CongViecPhoiHopResult { UserId = x, HoSoCongViecId = id }); } congViec.TrangThaiCongViecId = model.TrangThaiCongViecId; AddOrUpdatePhoiHop(id, congViec.CongViecPhoiHopResult); HoSoCongViecRepository.Update(congViec); return new JsonResult { JsonRequestBehavior = JsonRequestBehavior.AllowGet, Data = new { code = "SB01" } }; })); }