protected void listviewGratitude_ItemCommand(object sender, ListViewCommandEventArgs e) { if (e.Item != null) { ListViewDataItem dataItem = (ListViewDataItem)e.Item; Label lbGuestID = (Label)e.Item.FindControl("GuestID"); try { if (String.Equals(e.CommandName.ToLower(), "fix")) { KLGratitude grat = new KLGratitude(int.Parse(lbGuestID.Text)); WebUtils.SetupRedirect(this, SiteRoot + "/add-gratitude?GuestID=" + grat.GuestID); } else if (String.Equals(e.CommandName.ToLower(), "delete")) { int index = e.Item.DisplayIndex; listviewGratitude.DeleteItem(index); KLGratitude.Delete(int.Parse(lbGuestID.Text)); WebUtils.SetupRedirect(this, SiteRoot + "/add-gratitude"); } //int index = e.Item.DisplayIndex; //listviewGratitude.DeleteItem(index); //KLGratitude.Delete(int.Parse(lbGuestID.Text)); } catch (Exception ex) { log.Error(ex.Message); } } //WebUtils.SetupRedirect(this, Request.RawUrl); }
private int Save() { if (txtgratitude.Text.Trim() == "") { return(-1); } if (currentuser == null) { return(-1); } try { gratitude = new KLGratitude(); gratitude.Name = author.Name; gratitude.Avatar = author.Avatar; gratitude.AuthorID = author.AuthorID; gratitude.CreateUtc = DateTime.Now; gratitude.Comment = txtgratitude.Text; } catch (Exception ex) { log.Error(ex.Message); } if (gratitude.Save()) { LogActivity.Write("Post Gratitude", gratitude.Comment); message.SuccessMessage = ResourceHelper.GetResourceString("CustomResources", "PostSuccessMessage"); } return(gratitude.GuestID); }
private void loadParams() { authorID = WebUtils.ParseInt32FromQueryString("id", authorID); if (authorID > -1) { guests = KLGratitude.GetAll().Where(g => g.AuthorID == authorID).ToList(); } }
private void LoadSettings() { current = SiteUtils.GetCurrentSiteUser(); if (current != null) { aut = KLAuthor.GetKLAuthorByUserID(current.UserId); if (aut == null) { WebUtils.SetupRedirect(this, SiteRoot); } grat = KLGratitude.GetAll().Where(g => g.AuthorID == aut.AuthorID).ToList(); listviewGratitude.DataSource = grat.OrderByDescending(x => x.CreateUtc); listviewGratitude.DataBind(); GeneralVariables.NameAuthor = current.Name; GeneralVariables.Level = aut.LevelAuthor; } else { WebUtils.SetupRedirect(this, SiteRoot); } }
protected virtual void LoadSettings() { currentuser = SiteUtils.GetCurrentSiteUser(); author = KLAuthor.GetKLAuthorByUserID(currentuser.UserId); currentuser = SiteUtils.GetCurrentSiteUser(); if (currentuser == null) { WebUtils.SetupRedirect(this, SiteRoot); } else { author = KLAuthor.GetKLAuthorByUserID(currentuser.UserId); } guestid = WebUtils.ParseInt32FromQueryString("GuestID", guestid); if (guestid != -1) { gratitude = new KLGratitude(guestid); txtgratitude.Text = gratitude.Comment; } }
private void loadParams() { guest = KLGratitude.GetAll().OrderByDescending(g => g.CreateUtc).ToList(); }