public static void Update(PageViewModel target) { PageDao dao = new PageDao(); dao.Update(target.ToEntity()); s_logger.Debug($"UPDATE Page:{target}"); }
public static void Insert(PageViewModel target, DataOperationUnit dataOpUnit = null) { PageDao dao = new PageDao(); dao.Insert(target.ToEntity(), dataOpUnit?.CurrentConnection); s_logger.Debug($"INSERT Page:{target}"); }
private void CopyPages(ILibrary libManager, BookViewModel parent) { IDConversionDao idcDao = new IDConversionDao(); PageDao pageDao = new PageDao(); var pages = pageDao.FindBy(new Dictionary <string, object>() { { "BookID", parent.ID } }, _dataOpUnit.CurrentConnection, s_ANOTHER_DATABASE_ALIAS_NAME).OrderBy(p => p.PageIndex).ToViewModel(); foreach (var page in pages) { if (pageDao.FindBy(new Dictionary <string, object>() { { "ID", page.ID } }, _dataOpUnit.CurrentConnection).Count() > 0) { //対象ライブラリのエンティティを新規IDでインポートする。取込側ライブラリに新規IDと旧IDを記録する。 Guid newGuid = Guid.NewGuid(); idcDao.Insert(new Data.Entity.Migration.IDConversion("Page", newGuid, page.ID), _dataOpUnit.CurrentConnection); page.ID = newGuid; ImportPageWithContents(libManager, parent, page); } else { //対象ライブラリのエンティティを変更せずそのままインポートする。 ImportPageWithContents(libManager, parent, page); } } }
public ActionResult Edit(int id) { var model = new PageDao().GetById(id); var result = Mapper.Map <Page, PageViewModel>(model); return(View(result)); }
public ActionResult Edit(PageViewModel model) { try { if (ModelState.IsValid) { var session = (AdminLogin)Session[CommonConstants.ADMIN_SESSION]; var entity = new UserDao().GetByID(session.UserName); model.UpdatedBy = entity.UserName; var page = new Page(); page.UpdatePage(model); var result = new PageDao().Update(page); if (result) { SetAlert("Cập nhật thành công", "success"); return(RedirectToAction("Index", "Page")); } else { ModelState.AddModelError("", "Cập nhật thất bại"); } } return(View(model)); } catch { return(View()); } }
public static void IncrementPageIndex(Guid bookID, DataOperationUnit dataOpUnit = null) { PageDao dao = new PageDao(); dao.IncrementPageIndex(bookID, dataOpUnit?.CurrentConnection); s_logger.Debug($"UPDATE Page bookId:{bookID}"); }
public static void DeleteWhereIDIs(Guid id, DataOperationUnit dataOpUnit = null) { PageDao dao = new PageDao(); dao.DeleteWhereIDIs(id, dataOpUnit?.CurrentConnection); s_logger.Debug($"DELETE Page:{id}"); }
private void ImportPage(ILibrary libManager, BookViewModel parent, PageViewModel page) { PageDao pageDao = new PageDao(); pageDao.Insert(page.ToEntity(), _dataOpUnit.CurrentConnection); libManager.AccessDispatcherObject(() => parent.AddPage(page)); }
public override void DropTable(IConnection connection) { PageDao dao = new PageDao(typeof(VersionOrigin)); dao.CurrentConnection = connection; dao.DropTable(); ++ModifiedCount; }
private void EnumeratePages(BookViewModel parent) { PageDao pageDao = new PageDao(); _pages = pageDao.FindBy(new Dictionary <string, object>() { { "BookID", parent.ID } }, _dataOpUnit.CurrentConnection, s_ANOTHER_DATABASE_ALIAS_NAME).OrderBy(p => p.PageIndex).ToViewModel(); }
private void MapPageResourceToDao(PageResource p, PageDao dao) { dao.IsEnabled = p.IsEnabled; dao.Path = p.Path; dao.Alias = p.Alias; dao.MaintainCountryList(_dataContext, p.Countries); dao.OverridesSiteCountryList = p.Countries.Any(); }
public JsonResult ChangeStatus(int id) { var result = new PageDao().ChangeStatus(id); return(Json(new { status = result })); }
public static PageViewModel FindByImageId(Guid imageId) { var dao = new PageDao(); return(dao.FindBy(new Dictionary <string, object>() { { "ImageID", imageId } }).FirstOrDefault().ToViewModel());; }
public static int BookContentsCount(Guid bookID, DataOperationUnit dataOpUnit = null) { PageDao dao = new PageDao(); return(dao.CountBy(new Dictionary <string, object>() { { "BookID", bookID } }, dataOpUnit?.CurrentConnection)); }
public override void CreateTable(IConnection connection) { PageDao dao = new PageDao(typeof(VersionOrigin)); dao.CurrentConnection = connection; dao.CreateTableIfNotExists(); ++ModifiedCount; dao.CreateIndexIfNotExists(); ++ModifiedCount; }
public void UpdatePageIndexOnlyTest() { var id = new Guid("66F5EC93-FD2C-4DCC-A76B-5FE3D00C6E58"); var imageid = new Guid("83506829-1661-4329-8C43-8AE858F00F02"); var bookid = new Guid("9277ACAF-AB93-47B2-BE04-92566DE6F190"); var pageindex = int.MaxValue; var title = "Inserted page"; var page = new Page(); page.ID = id; page.ImageID = imageid; page.BookID = bookid; page.PageIndex = pageindex; page.Title = title; PageDao dao = new PageDao(); dao.Insert(page); var records = dao.FindBy(new Dictionary <string, object>() { { "ID", id } }); Assert.That(records.Count(), Is.EqualTo(1)); var record = records.Single(); Assert.That(record.ID, Is.EqualTo(id)); Assert.That(record.ImageID, Is.EqualTo(imageid)); Assert.That(record.BookID, Is.EqualTo(bookid)); Assert.That(record.PageIndex, Is.EqualTo(pageindex)); Assert.That(record.Title, Is.EqualTo(title)); //Change page.PageIndex = 1; dao.Update(page); records = dao.FindBy(new Dictionary <string, object>() { { "ID", id } }); Assert.That(records.Count(), Is.EqualTo(1)); record = records.Single(); Assert.That(record.ID, Is.EqualTo(id)); Assert.That(record.ImageID, Is.EqualTo(imageid)); Assert.That(record.BookID, Is.EqualTo(bookid)); Assert.That(record.PageIndex, Is.EqualTo(1)); Assert.That(record.Title, Is.EqualTo(title)); }
private void MapSiteResourceToDao(SiteResource resource, SiteDao siteDao) { if (resource.Pages == null) { resource.Pages = new List <PageResource>(); } siteDao.Domain = resource.Domain; siteDao.IsEnabled = resource.IsEnabled; siteDao.MaintainCountryList(_dataContext, resource.Countries); var incomingPaths = resource.Pages.ToDictionary(p => p.Path); var currentPaths = siteDao.Pages.ToDictionary(p => p.Path); var newPaths = incomingPaths.Keys.Except(currentPaths.Keys).ToList(); var deletedPaths = currentPaths.Keys.Except(incomingPaths.Keys).ToList(); var commonPaths = currentPaths.Keys.Intersect(incomingPaths.Keys).ToList(); foreach (var p in newPaths) { var dao = new PageDao(); MapPageResourceToDao(incomingPaths[p], dao); siteDao.Pages.Add(dao); } foreach (var p in deletedPaths) { siteDao.Pages.Remove(currentPaths[p]); } foreach (var p in commonPaths) { var currentPage = currentPaths[p]; var pageresource = incomingPaths[p]; MapPageResourceToDao(pageresource, currentPage); } }
public static IEnumerable <PageViewModel> FindByBookId(Guid bookId, int challengeMaxCount = 3) { List <Exception> trying = new List <Exception>(); while (trying.Count() < challengeMaxCount) { try { PageDao dao = new PageDao(); return(dao.FindBy(new Dictionary <string, object>() { { "BookID", bookId } }).ToViewModel()); } catch (SQLiteException e) { trying.Add(e); Thread.Sleep(500); continue; } } throw new QueryFailedException($"設定回数({challengeMaxCount})の問い合わせに失敗しました.", trying); }
public ActionResult Index() { var model = new PageDao().ListAll(); return(View(model)); }
public static void GetProperty(ref PageViewModel page, DataOperationUnit dataOpUnit = null) { var dao = new PageDao(); dao.GetProperty(ref page, dataOpUnit?.CurrentConnection); }
public static IEnumerable <PageViewModel> FindAll(DataOperationUnit dataOpUnit = null) { PageDao dao = new PageDao(); return(dao.FindAll().ToViewModel()); }
public static PageViewModel FindByBookIdTop1(Guid bookId, DataOperationUnit dataOpUnit = null) { PageDao dao = new PageDao(); return(dao.FindByBookIdTop1(bookId, dataOpUnit?.CurrentConnection).FirstOrDefault().ToViewModel()); }
public static long CountAll() { var dao = new PageDao(); return(dao.CountAll()); }