protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext) { using (var db = DatabaseHelper.GetDashboardData()) { var newPage = new Page(); newPage.UserId = UserId; newPage.Title = Title; newPage.CreatedDate = DateTime.Now; newPage.LastUpdate = DateTime.Now; newPage.LayoutType = Convert.ToInt32(LayoutType); DatabaseHelper.Insert<Page>(newPage); NewPageId = newPage.ID; var page = db.Pages.Single<Page>(p => p.ID == NewPageId); this.NewPage = page; } return ActivityExecutionStatus.Closed; }
protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext) { string pageName = this.PageName; using (var db = DatabaseHelper.GetDashboardData()) { List<Page> userPages = db.Pages.Where<Page>(p => p.UserId == UserGuid).ToList(); // Find the page that has the specified Page Name and make it as current // page. This is needed to make a tab as current tab when the tab name is // known if (!string.IsNullOrEmpty(pageName)) { foreach (Page page in userPages) { if (page.Title.Replace(' ', '_') == pageName) { this.CurrentPageId = page.ID; this.CurrentPage = page; break; } } } // If there's no such page, then the first page user has will be the current // page. This happens when a page is deleted. if (this.CurrentPageId == 0) { this.CurrentPageId = userPages[0].ID; this.CurrentPage = userPages[0]; } } return ActivityExecutionStatus.Closed; }
private void detach_Pages(Page entity) { this.SendPropertyChanging(); entity.aspnet_User = null; }
private void attach_Pages(Page entity) { this.SendPropertyChanging(); entity.aspnet_User = this; }
partial void DeletePage(Page instance);
partial void UpdatePage(Page instance);
partial void InsertPage(Page instance);
protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext) { using( new TimedLog(UserGuid.ToString(), "Activity: Get User Setting") ) { using (var db = DatabaseHelper.GetDashboardData()) { var query = from u in db.UserSettings where u.UserId == UserGuid select u; IEnumerator<UserSetting> e = query.GetEnumerator(); if (e.MoveNext()) { this.UserSetting = e.Current; } else { // No setting saved before. Create default setting UserSetting newSetting = new UserSetting(); newSetting.UserId = UserGuid; newSetting.CurrentPageId = (from page in db.Pages where page.UserId == UserGuid select page.ID).First(); db.UserSettings.InsertOnSubmit(newSetting); db.SubmitChanges(); this.UserSetting = newSetting; } // Get users current page and if not available, get the first page this.CurrentPage = db.Pages.SingleOrDefault(page => page.ID == this.UserSetting.CurrentPageId) ?? db.Pages.First(page => page.UserId == this.UserGuid); } return ActivityExecutionStatus.Closed; } }
private void RedirectToTab(Page page) { Response.Redirect('?' + page.TabName()); }