/// <summary> /// Get about page with different variables /// </summary> /// <returns>Returns about page</returns> public ActionResult About() { ViewBag.Message = "Om oss"; var AboutList = _context.About.ToList(); var About = new DbTables.Info(); if (AboutList.Any()) { About = AboutList.First(); } var TwitterList = _context.Twitter.ToList(); var Twitter = new DbTables.Twitter(); if (TwitterList.Any()) { Twitter = TwitterList.First(); } var FacebookList = _context.Facebook.ToList(); var Facebook = new DbTables.Facebook(); if (FacebookList.Any()) { Facebook = FacebookList.First(); } //var style = "background:url(/File/Background?id="+") no-repeat center center fixed"; var background = new DbTables.BackgroundImage(); var backgroundList = _context.BackgroundImage.ToList(); if (backgroundList.Any()) { background = backgroundList.First(); if (background.Enabeled) { ViewBag.Style = "background:url('/File/Background?id=" + background.Image.FileId + "') no-repeat center center fixed;-webkit-background-size: cover;-moz-background-size: cover;-o-background-size: cover;background-size: cove;overflow-x: hidden;"; ViewBag.BackGround = "background-color:transparent;"; } } var AboutModel = new AboutModel { About = About, Facebook = Facebook, Twitter = Twitter }; return(View(AboutModel)); }
/// <summary> /// Edit values /// </summary> /// <param name="model">Model values to change</param> /// <returns>view with updated info and success/failure message</returns> public ActionResult EditAbout(DbTables.Info model) { if (ModelState.IsValid) { try { var About = new DbTables.Info(); var AboutList = _context.About.ToList(); if (AboutList.Any()) { About = AboutList.First(); About.Phone = model.Phone; About.About = model.About; About.Email = model.Email; About.DonateText = model.DonateText; About.MembershipText = model.MembershipText; var adress = new AboutAdress { StreetAdress = model.Adress.StreetAdress, City = model.Adress.City, PostCode = model.Adress.PostCode, County = model.Adress.County }; About.Adress = adress; } else { About.Phone = model.Phone; About.About = model.About; About.Email = model.Email; About.DonateText = model.DonateText; About.MembershipText = model.MembershipText; var adress = new AboutAdress { StreetAdress = model.Adress.StreetAdress, City = model.Adress.City, PostCode = model.Adress.PostCode, County = model.Adress.County }; About.Adress = adress; _context.About.Add(About); } _context.SaveChanges(); ViewBag.Success = "Sideinformasjonen ble oppdatert"; return(PartialView("_AboutPartial", _context.About.First())); } catch (EntityException ex) { ViewBag.Error = "Error: " + ex.Message; return(PartialView("_AboutPartial", _context.About.First())); } } var ErrorAbout = new DbTables.Info(); var ErrorAboutList = _context.About.ToList(); if (ErrorAboutList.Any()) { ErrorAbout = ErrorAboutList.First(); } var messages = string.Join("r\n\r\n", ModelState.Values .SelectMany(x => x.Errors) .Select(x => x.ErrorMessage)); ViewBag.Error = "Ugyldige verdier: " + messages; return(PartialView("_AboutPartial", ErrorAbout)); }
// GET: Admin/Various /// <summary> /// Index view of various, check if various database elements are actually added and then add these to the model if /// they exist /// </summary> /// <returns>Various index view</returns> public ActionResult Index() { var carouselObj = new DbTables.Carousel(); var GoogleCap = new DbTables.GoogleCaptchaAPI(); var GoogleCapList = _context.GoogleCaptchaAPI.ToList(); if (GoogleCapList.Any()) { GoogleCap = GoogleCapList.First(); } var SendG = new DbTables.SendGridAPI(); var SendgridList = _context.SendGridAPI.ToList(); if (SendgridList.Any()) { SendG = SendgridList.First(); } var Stripe = new DbTables.StripeAPI(); var StripeList = _context.StripeAPI.ToList(); if (StripeList.Any()) { Stripe = StripeList.First(); } var Facebook = new DbTables.Facebook(); var FacebookList = _context.Facebook.ToList(); if (FacebookList.Any()) { Facebook = FacebookList.First(); } var Twitter = new DbTables.Twitter(); var TwitterList = _context.Twitter.ToList(); if (TwitterList.Any()) { Twitter = TwitterList.First(); } var Disqus = new DbTables.Disqus(); var DisqusList = _context.Disqus.ToList(); if (DisqusList.Any()) { Disqus = DisqusList.First(); } var About = new DbTables.Info(); var AboutList = _context.About.ToList(); if (AboutList.Any()) { About = AboutList.First(); } var carousel = _context.Carousel.ToList(); if (carousel.Any()) { carouselObj = carousel.First(); } var Terms = new DbTables.TermsOfUse(); var TermsList = _context.TermsOfUse.ToList(); if (TermsList.Any()) { Terms = TermsList.First(); } var Background = new DbTables.BackgroundImage(); var BackgroundList = _context.BackgroundImage.ToList(); if (BackgroundList.Any()) { Background = BackgroundList.First(); } var model = new VariousModel { GoogleCaptchaAPI = GoogleCap, SendGridAPI = SendG, Terms = Terms, Carousel = carouselObj, About = About, StripeAPI = Stripe, Twitter = Twitter, Facebook = Facebook, Background = Background, Disqus = Disqus }; return(View(model)); }
public int imageNum = 3; //Images to get each time we get new ones /// <summary> /// Gets the front page view with images and information /// </summary> /// <returns>Returns the view to the front page of the website</returns> public ActionResult Index() { var articles = filterArticles(0, articleNum); var carousel = _context.Carousel.ToList(); IList <CarouselObject> carouselList = new List <CarouselObject>(); if (carousel.Any() && carousel.First().Enabeled) { foreach (var file in carousel.First().CarouselItems) { if (file.FileType == DbTables.FileType.CarouselImage) { carouselList.Add(new CarouselObject { id = file.FileId, type = "image" }); } else { carouselList.Add(new CarouselObject { id = file.FileId, type = "video" }); } } } else { carouselList = null; } var About = new DbTables.Info(); //get about model var AboutList = _context.About.ToList(); if (AboutList.Any()) { About = AboutList.First(); } var background = new DbTables.BackgroundImage(); var backgroundList = _context.BackgroundImage.ToList(); if (backgroundList.Any()) { background = backgroundList.First(); if (background.Enabeled) //if background is in database and available, return { ViewBag.Style = "background:url('/File/Background?id=" + background.Image.FileId + //adds background to viewbag "') no-repeat center center fixed;-webkit-background-size: cover;-moz-background-size: cover;-o-background-size: cover;background-size: cove;overflow-x: hidden;"; ViewBag.BackGround = "background-color:transparent;"; } } var stripeList = _context.StripeAPI.ToList(); if (stripeList.Any()) { if (stripeList.First().Enabeled) { ViewBag.StripePublic = stripeList.First().Public; } } var subscriptions = _context.Subscriptions.Where(s => s.Enabeled).ToList(); var donations = new Donations { Subscriptions = subscriptions }; if (!string.IsNullOrEmpty(About.DonateText)) { donations.DonationText = About.DonateText; } var model = new FrontPageModel { Articles = articles, Carousel = carouselList, About = About, Donations = donations }; return(View(model)); }