/// <summary> /// Edit values /// </summary> /// <param name="model">Model values to change</param> /// <returns>view with updated info and success/failure message</returns> public ActionResult EditStripe(DbTables.StripeAPI model) { try { var Stripe = new DbTables.StripeAPI(); var StripeList = _context.StripeAPI.ToList(); if (StripeList.Any()) { Stripe = StripeList.First(); Stripe.Public = model.Public; Stripe.Secret = model.Secret; } else { Stripe.Public = model.Public; Stripe.Secret = model.Secret; _context.StripeAPI.Add(Stripe); } _context.SaveChanges(); ViewBag.Success = "Stripe API variabler ble sukessfult oppdatert"; return(PartialView("_StripePartial", _context.StripeAPI.First())); } catch (EntityException ex) { ViewBag.Error = "Error:" + ex.Message; return(PartialView("_StripePartial", _context.StripeAPI.First())); } }
// 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)); }