public ActionResult Current() { User u = _WebSiteModuleManager.EnsureCurrentUser(); return(new JsonNetResult() { Data = u }); }
public PageTemplatesDto GetPageTemplates(string templatedPageTitle) { var pageTemplateDto = new PageTemplatesDto(); var user = WebSiteModuleManager.EnsureCurrentUser(); var primaryTeamMembership = user.TeamMemberships.FirstOrDefault(t => t.PrimaryTeamMembership); if (primaryTeamMembership == null) { return(SetDefaultTemplateValues()); } var templateList = new List <PageTemplateDto>(); using (ConsoleRepository) { var page = ConsoleRepository.Query <TemplatedPage>().FirstOrDefault(tp => tp.PageTitle == templatedPageTitle); var pageTemplates = ConsoleRepository.Query <PageTemplate>(pt => pt.Template, pt => pt.TemplatedPage, pt => pt.Team) .Where(pt => pt.TemplatedPageId == page.Id && pt.TeamId == primaryTeamMembership.TeamId); var userPageTemplateSettings = ConsoleRepository.Query <UserPageTemplateSetting>() .Where(pt => pt.TemplatedPageId == page.Id && pt.TeamId == primaryTeamMembership.TeamId && pt.UserId == user.Id); var query = from s in pageTemplates join upts in userPageTemplateSettings on new { s.TemplateId, s.PageSectionId } equals new { upts.TemplateId, upts.PageSectionId } into gj from subpet in gj.DefaultIfEmpty() select new PageTemplateDto() { //Id = s.Id, TemplateId = s.TemplateId, TeamId = s.TeamId, TemplatedPageId = s.TemplatedPageId, TemplateTitle = s.Template.Title, TemplateUrl = s.Template.Url, TemplateAfterRenderDomFunction = s.Template.AfterRenderDomFunction, IsVisible = s.IsVisible, IsReadOnly = s.IsReadOnly, IsSiteStructureTemplate = s.Template.IsPageStructureTemplate, PageSectionId = s.PageSectionId, SendConnectionKeys = s.SendConnectionKeys, ReceiveConnectionKeys = s.ReceiveConnectionKeys, Settings = s.Settings, PersonalSettings = subpet.Settings }; var results = query.ToList(); if (results == null || results.Count == 0) { throw new Exception("Page Templates not found"); } var pageStructureTemplate = results.FirstOrDefault(pt => pt.IsSiteStructureTemplate); if (pageStructureTemplate != null) { pageTemplateDto.PageStructureTemplateId = pageStructureTemplate.TemplateId; pageTemplateDto.PageStructureTemplateTitle = pageStructureTemplate.TemplateTitle; pageTemplateDto.PageStructureTemplateUrl = pageStructureTemplate.TemplateUrl; results.Remove(pageStructureTemplate); pageTemplateDto.SectionTemplates = results; } } return(pageTemplateDto); }