public void SyncDataToTblReposDetailFromGithub(List <TblReposDetail> tblReposDetails) { tblReposDetails.ForEach(tblReposDetail => { if (tblReposDetailRepository.GetAll().Any(a => a.ReposId == tblReposDetail.ReposId)) { var tblReposDetailTemp = tblReposDetailRepository.GetAll().FirstOrDefault(a => a.ReposId == tblReposDetail.ReposId); tblReposDetailTemp.Language = tblReposDetail.Language; tblReposDetailTemp.ReposName = tblReposDetail.ReposName; tblReposDetailTemp.Description = tblReposDetail.Description; tblReposDetailTemp.ModifiedOn = DateTime.Now; } else { tblReposDetailRepository.Add(tblReposDetail); } }); unitOfWork.Commit(); tblReposDetails = tblReposDetailRepository.GetAll().ToList(); tblReposDetails.ForEach(tblReposDetail => { if (!tblLeftRepository.GetAll().Any(a => a.TblReposDetailId == tblReposDetail.Id)) { var tblLeft = new TblLeft() { TblReposDetailId = tblReposDetail.Id }; tblLeftRepository.Add(tblLeft); } }); var tbLefts = tblLeftRepository.GetAll().ToList(); var tbRights = tblRightRepository.GetAll().ToList(); tbLefts.ForEach(tblLeft => { if (!tblReposDetails.Any(a => a.Id == tblLeft.TblReposDetailId)) { tblLeft.IsDeleted = true; tblLeft.DeletedDescription = "数据源不存在,同步删除"; } }); tbRights.ForEach(tbRight => { if (!tblReposDetails.Any(a => a.Id == tbRight.TblReposDetailId)) { tbRight.IsDeleted = true; tbRight.DeletedDescription = "数据源不存在,同步删除"; } }); }
public async Task PullLeft(int tblReposDetailId) { var tblRight = tblRightRepository.GetAll().FirstOrDefault(a => a.TblReposDetailId == tblReposDetailId); tblRight.IsDeleted = true; if (tblLeftRepository.GetAll().Any(a => a.TblReposDetailId == tblReposDetailId)) { var tblLeft = tblLeftRepository.GetAll().FirstOrDefault(a => a.TblReposDetailId == tblReposDetailId); tblLeft.IsDeleted = false; } else { var tblLeft = new TblLeft() { TblReposDetailId = tblReposDetailId }; await tblLeftRepository.AddAsync(tblLeft); } }