public ContentHead Post(string id, [FromBody] int selectedAlternative) { ContentHead contentHead = cms.GetContent(id); cms.ParseContentData(contentHead); if (selectedAlternative == 1) { contentHead.CONTENT.TotalVotes1 += 1; } if (selectedAlternative == 2) { contentHead.CONTENT.TotalVotes2 += 1; } if (selectedAlternative == 3) { contentHead.CONTENT.TotalVotes3 += 1; } if (selectedAlternative == 4) { contentHead.CONTENT.TotalVotes4 += 1; } if (selectedAlternative == 5) { contentHead.CONTENT.TotalVotes5 += 1; } decimal total = SumOfAlternatives(contentHead.CONTENT); //Calculates percent for all alternatives contentHead.CONTENT.Percent1 = (contentHead.CONTENT.TotalVotes1 / total) * 100; contentHead.CONTENT.Percent2 = (contentHead.CONTENT.TotalVotes2 / total) * 100; contentHead.CONTENT.Percent3 = (contentHead.CONTENT.TotalVotes3 / total) * 100; contentHead.CONTENT.Percent4 = (contentHead.CONTENT.TotalVotes4 / total) * 100; contentHead.CONTENT.Percent5 = (contentHead.CONTENT.TotalVotes5 / total) * 100; contentHead.Data.JSON = contentHead.CONTENT.ToString(); cms.SaveContent(contentHead); //PageviewCount means number of votes SiteService site = new Box.CMS.Services.SiteService(); site.LogPageView(id); return(contentHead); }
protected override void InitializePage() { base.InitializePage(); string id = this.TempData["id"] as string; SiteService site = new Box.CMS.Services.SiteService(); HEAD = site.GetContent(id); if (HEAD == null) throw new System.Web.HttpException(404, "page not found"); site.LogPageView(id); CONTENT_URL = Request.Url.Scheme + "://" + Request.Url.Host + (Request.Url.Port!=80?":" + Request.Url.Port:"") + HEAD.Location+HEAD.CanonicalName; CONTENT = HEAD.CONTENT; }
protected override void InitializePage() { base.InitializePage(); string id = UrlData[0]; SiteService site = new Box.CMS.Services.SiteService(); HEAD = site.GetContent(id); if (HEAD == null) { throw new System.Web.HttpException(404, "page not found"); } site.LogPageView(id); CONTENT_URL = Request.Url.Scheme + "://" + Request.Url.Host + (Request.Url.Port != 80?":" + Request.Url.Port:"") + HEAD.Location + HEAD.CanonicalName; CONTENT = HEAD.CONTENT; }
public ContentHead Post(string id, [FromBody] int selectedAlternative) { ContentHead contentHead = cms.GetContent(id); cms.ParseContentData(contentHead); if(selectedAlternative == 1) contentHead.CONTENT.TotalVotes1 += 1; if(selectedAlternative == 2) contentHead.CONTENT.TotalVotes2 += 1; if(selectedAlternative == 3) contentHead.CONTENT.TotalVotes3 += 1; if(selectedAlternative == 4) contentHead.CONTENT.TotalVotes4 += 1; if(selectedAlternative == 5) contentHead.CONTENT.TotalVotes5 += 1; decimal total = SumOfAlternatives(contentHead.CONTENT); //Calculates percent for all alternatives contentHead.CONTENT.Percent1 = (contentHead.CONTENT.TotalVotes1 / total) * 100; contentHead.CONTENT.Percent2 = (contentHead.CONTENT.TotalVotes2 / total) * 100; contentHead.CONTENT.Percent3 = (contentHead.CONTENT.TotalVotes3 / total) * 100; contentHead.CONTENT.Percent4 = (contentHead.CONTENT.TotalVotes4 / total) * 100; contentHead.CONTENT.Percent5 = (contentHead.CONTENT.TotalVotes5 / total) * 100; contentHead.Data.JSON = contentHead.CONTENT.ToString(); cms.SaveContent(contentHead); //PageviewCount means number of votes SiteService site = new Box.CMS.Services.SiteService(); site.LogPageView(id); return contentHead; }