private void CopyImageTag(ILibrary libManager, BookViewModel book) { IDConversionDao idcDao = new IDConversionDao(); ImageTagDao itDao = new ImageTagDao(); var imageTags = itDao.FindByBookId(s_ANOTHER_DATABASE_ALIAS_NAME, book.ID, _dataOpUnit.CurrentConnection).ToList().ToViewModel(); foreach (var imageTag in imageTags) { var byImageId = idcDao.FindBy(new Dictionary <string, object>() { { "TableName", "Image" }, { "ForeignID", imageTag.ImageID } }, _dataOpUnit.CurrentConnection); var byTagId = idcDao.FindBy(new Dictionary <string, object>() { { "TableName", "Tag" }, { "ForeignID", imageTag.ImageID } }, _dataOpUnit.CurrentConnection); if (byImageId.Count() == 1) { imageTag.ImageID = byImageId.Single().DomesticID; } if (byTagId.Count() == 1) { imageTag.TagID = byTagId.Single().DomesticID; } itDao.Insert(imageTag.ToEntity(), _dataOpUnit.CurrentConnection); libManager.TagManager.Chains.Add(imageTag); } libManager.TagManager.ObserveTagCount(); }
private void SetAuthorTo(IAuthorManager authorManager, BookViewModel add) { IDConversionDao idcDao = new IDConversionDao(); AuthorDao authorDao = new AuthorDao(); var idc = idcDao.FindBy(new Dictionary <string, object>() { { "TableName", "Author" }, { "ForeignID", add.AuthorID } }, _dataOpUnit.CurrentConnection); if (idc.Count() == 1) { add.Author = authorDao.FindBy(new Dictionary <string, object>() { { "ID", idc.Single().DomesticID } }, _dataOpUnit.CurrentConnection).SingleOrDefault().ToViewModel(); } else { add.Author = authorDao.FindBy(new Dictionary <string, object>() { { "ID", add.AuthorID } }, _dataOpUnit.CurrentConnection).SingleOrDefault().ToViewModel(); } authorManager.ObserveAuthorCount(); }