public void EditPageContent(PageContent pageContent) { var pageContentToEdit = GetPageContent(pageContent.PageContentId); pageContentToEdit.OrderNumber = pageContent.OrderNumber; pageContentToEdit.YPlaceId = pageContent.YPlaceId; pageContentToEdit.XPlaceId = pageContent.XPlaceId; _db.SaveChanges(); }
private void SavePageContentOrder(PageContent pageContent, int pageContentId, int yPlaceId, int xPlaceId, int orderNumber, List<PageContent> pageContents) { var pageContentsToOrder = pageContents.Where(p => p.YPlaceId == yPlaceId && p.XPlaceId == xPlaceId && p.PageContentId != pageContentId).OrderBy(p => p.OrderNumber).ToList(); var i = 1; var isPageUpdated = false; foreach (var p in pageContentsToOrder) { if (orderNumber == i && pageContent != null) { _pageManager.EditPageContent(PreparePageContent(pageContent, orderNumber, yPlaceId, xPlaceId)); i++; isPageUpdated = true; } p.OrderNumber = i++; _pageManager.EditPageContent(p); } if (!isPageUpdated && pageContent != null) { _pageManager.EditPageContent(PreparePageContent(pageContent, orderNumber, yPlaceId, xPlaceId)); } }
private PageContent PreparePageContent(PageContent pageContent, int orderNumber, int yPlaceId, int xPlaceId) { pageContent.OrderNumber = orderNumber; pageContent.YPlaceId = yPlaceId; pageContent.XPlaceId = xPlaceId; return pageContent; }
public void EditPageContent(PageContent pageContent) { _pageRepository.EditPageContent(pageContent); }