public ResponseModel Delete(ClientMenu clientMenu) { return _clientMenuRepository.Delete(clientMenu); }
public ResponseModel Update(ClientMenu clientMenu) { return _clientMenuRepository.Update(clientMenu); }
/// <summary> /// /// </summary> /// <param name="pageId"></param> /// <returns></returns> public ResponseModel SavePageToClientMenu(int pageId) { var page = _pageRepository.GetById(pageId); var clientMenu = FetchFirst(c => c.PageId == pageId); if (clientMenu != null) { clientMenu.Name = page.Title; clientMenu.PageId = page.Id; clientMenu.Url = page.FriendlyUrl; if (page.ParentId.HasValue && page.Page1.ClientMenus.Any()) { clientMenu.ParentId = page.Page1.ClientMenus.First().Id; } else { clientMenu.ParentId = null; } clientMenu.IncludeInSiteNavigation = page.IncludeInSiteNavigation; clientMenu.StartPublishingDate = page.StartPublishingDate; clientMenu.EndPublishingDate = page.EndPublishingDate; if(page.RecordOrder * 10 != clientMenu.RecordOrder) { var relativePages = _pageRepository.Fetch(p => (page.ParentId.HasValue ? p.ParentId == page.ParentId : !p.ParentId.HasValue) && p.Id != page.Id); foreach (var relativePage in relativePages) { var relativeMenu = relativePage.ClientMenus.First(); relativeMenu.RecordOrder = relativePage.RecordOrder * 10; Update(relativeMenu); } clientMenu.RecordOrder = page.RecordOrder * 10; } clientMenu.RecordActive = page.RecordActive; return HierarchyUpdate(clientMenu); } clientMenu = new ClientMenu(page); return HierarchyInsert(clientMenu); }
/// <summary> /// Save client menu manage model /// </summary> /// <param name="model"></param> /// <returns></returns> public ResponseModel SaveClientMenuManageModel(ClientMenuManageModel model) { ClientMenu relativeMenu; ResponseModel response; var clientMenu = GetById(model.Id); #region Edit ClientMenu if (clientMenu != null) { clientMenu.Name = model.Name; clientMenu.IncludeInSiteNavigation = model.IncludeInSiteNavigation; clientMenu.StartPublishingDate = model.StartPublishingDate; clientMenu.EndPublishingDate = model.EndPublishingDate; //Parse url clientMenu.Url = string.IsNullOrWhiteSpace(model.Url) ? model.Name.ToUrlString() : model.Url.ToUrlString(); //Get page record order relativeMenu = GetById(model.RelativeMenuId); if (relativeMenu != null) { if (model.Position == (int)ClientMenuEnums.PositionEnums.Before) { clientMenu.RecordOrder = relativeMenu.RecordOrder; var query = string.Format( "Update ClientMenus set RecordOrder = RecordOrder + 1 Where {0} And RecordOrder >= {1}", relativeMenu.ParentId.HasValue ? string.Format(" ParentId = {0}", relativeMenu.ParentId) : "ParentId Is NULL", relativeMenu.RecordOrder); _pageRepository.ExcuteSql(query); } else { clientMenu.RecordOrder = relativeMenu.RecordOrder + 1; var query = string.Format( "Update ClientMenus set RecordOrder = RecordOrder + 1 Where {0} And RecordOrder > {1}", relativeMenu.ParentId.HasValue ? string.Format(" ParentId = {0}", relativeMenu.ParentId) : "ParentId Is NULL", relativeMenu.RecordOrder); _pageRepository.ExcuteSql(query); } } clientMenu.ParentId = model.ParentId; response = HierarchyUpdate(clientMenu); return response.SetMessage(response.Success ? _localizedResourceServices.T("AdminModule:::ClientMenus:::Messages:::UpdateSuccessfully:::Update client menu successfully.") : _localizedResourceServices.T("AdminModule:::ClientMenus:::Messages:::UpdateFailure:::Update client menu failed. Please try again later.")); } #endregion clientMenu = new ClientMenu { Name = model.Name, ParentId = model.ParentId, IncludeInSiteNavigation = model.IncludeInSiteNavigation, StartPublishingDate = model.StartPublishingDate, EndPublishingDate = model.EndPublishingDate, Url = string.IsNullOrWhiteSpace(model.Url) ? model.Name.ToUrlString() : model.Url.ToUrlString() }; //Get menu record order relativeMenu = GetById(model.RelativeMenuId); if (relativeMenu != null) { if (model.Position == (int)ClientMenuEnums.PositionEnums.Before) { clientMenu.RecordOrder = relativeMenu.RecordOrder - 1; } else { clientMenu.RecordOrder = relativeMenu.RecordOrder + 1; } } response = HierarchyInsert(clientMenu); return response.SetMessage(response.Success ? _localizedResourceServices.T("AdminModule:::ClientMenus:::Messages:::CreateSuccessfully:::Create client menu successfully.") : _localizedResourceServices.T("AdminModule:::ClientMenus:::Messages:::CreateFailure:::Create client menu failed. Please try again later.")); }
public ResponseModel Insert(ClientMenu clientMenu) { return _clientMenuRepository.Insert(clientMenu); }
public ResponseModel HierarchyUpdate(ClientMenu clientMenu) { return _clientMenuRepository.HierarchyUpdate(clientMenu); }
public ResponseModel HierarchyInsert(ClientMenu clientMenu) { return _clientMenuRepository.HierarchyInsert(clientMenu); }