public ActionResult Login(string returnUrl, string message) { ViewBag.message = message; 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 sendgridList = _context.SendGridAPI.ToList(); if (sendgridList.Any()) { if (sendgridList.First().Enabeled) { ViewBag.Sendgrid = "true"; } } ViewBag.ReturnUrl = returnUrl; return(View()); }
public async Task <ActionResult> SetPassword(SetPasswordViewModel model) { 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;"; } } if (ModelState.IsValid) { var result = await UserManager.AddPasswordAsync(User.Identity.GetUserId(), model.NewPassword); if (result.Succeeded) { var user = await UserManager.FindByIdAsync(User.Identity.GetUserId()); if (user != null) { await SignInManager.SignInAsync(user, false, false); } return(RedirectToAction("Index", new { Message = ManageMessageId.SetPasswordSuccess })); } AddErrors(result); } // If we got this far, something failed, redisplay form return(View(model)); }
public ActionResult MyImages() { var manager = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(new ApplicationDbContext())); var currentUser = manager.FindByIdAsync(User.Identity.GetUserId()).Result; if (currentUser == null) { return(HttpNotFound()); } var startId = 0; //id of first image i client var images = filterImages(currentUser, startId, imageNum); 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;"; } } return(View(new MyImagesModel { Images = images, StartId = 0 })); }
/// <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)); }
public ActionResult RequestMembership() { ViewBag.Message = "Forespør Medlemskap."; var GoogleCaptcha = new DbTables.GoogleCaptchaAPI(); var GoogleCaptchaList = _context.GoogleCaptchaAPI.ToList(); var model = new RequestModel { MembershipRequest = new DbTables.MembershipRequest(), SiteKey = GoogleCaptcha.SiteKey }; if (GoogleCaptchaList.Any()) { //check if there are google recaptcha element in the database, add to model if true if (GoogleCaptchaList.First().Enabeled) { model.SiteKey = GoogleCaptchaList.First().SiteKey; } } var terms = _context.TermsOfUse.ToList(); var Terms = new DbTables.TermsOfUse(); if (terms.Any()) //check if there are any terms of use in the database { Terms = terms.First(); if (Terms.Enabeled && (Terms.Terms.FileId != 0)) { model.TermsID = Terms.Terms.FileId; } } 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;"; } } return(View(model)); }
public ActionResult ResetPasswordConfirmation() { 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;"; } } return(View()); }
public ActionResult LogOff() { 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;"; } } AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie); return(RedirectToAction("Index", "Home")); }
public async Task <ActionResult> Login(LoginViewModel model, string returnUrl) { 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;"; } } if (!ModelState.IsValid) { return(View(model)); } // This doesn't count login failures towards account lockout // To enable password failures to trigger account lockout, change to shouldLockout: true var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, false); switch (result) { case SignInStatus.Success: return(RedirectToLocal(returnUrl)); case SignInStatus.LockedOut: return(View("Lockout")); case SignInStatus.RequiresVerification: return(RedirectToAction("SendCode", new { ReturnUrl = returnUrl, model.RememberMe })); case SignInStatus.Failure: default: ModelState.AddModelError("", "Ugyldig innlogging"); return(View(model)); } }
public async Task <ActionResult> ForgotPassword(ForgotPasswordViewModel model) { 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;"; } } if (ModelState.IsValid) { var user = await UserManager.FindByNameAsync(model.Email); if (user == null) { return(View("ForgotPasswordConfirmation")); } var provider = new DpapiDataProtectionProvider("ButterflyFriends"); UserManager.UserTokenProvider = new DataProtectorTokenProvider <ApplicationUser>(provider.Create("Passwordresetting")); var code = await UserManager.GeneratePasswordResetTokenAsync(user.Id); var callbackUrl = Url.Action("ResetPassword", "Account", new { userId = user.Id, code, area = "" }, Request.Url.Scheme); if (!SendEmail(user, callbackUrl)) { return(RedirectToAction("Login", "Account", new { message = "Sendgrid er ikke konfigurert for applikasjonen eller slått av" })); } return(RedirectToAction("ForgotPasswordConfirmation", "Account")); } // If we got this far, something failed, redisplay form return(View(model)); }
public ActionResult Article(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var article = _context.Articles.Find(id); if ((article == null) || !article.Published) { return(HttpNotFound()); } 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 disqus = new DbTables.Disqus(); var disqusList = _context.Disqus.ToList(); if (disqusList.Any()) { disqus = disqusList.First(); if (disqus.Enabeled && !string.IsNullOrEmpty(disqus.DisqusUrl)) //check if we should load in disqus { ViewBag.Disqus = disqus.DisqusUrl; } } return(View(article)); }
public async Task <ActionResult> SetPassword(SetPasswordViewModel model) { 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;"; } } if (!ModelState.IsValid) { return(View(model)); } var user = await UserManager.FindByIdAsync(model.userId); if (user == null) { return(RedirectToAction("SetPasswordConfirmation", "Account")); } var provider = new DpapiDataProtectionProvider("ButterflyFriends"); UserManager.UserTokenProvider = new DataProtectorTokenProvider <ApplicationUser>(provider.Create("Passwordresetting")); var result = await UserManager.ResetPasswordAsync(user.Id, model.Code, model.NewPassword); if (result.Succeeded) { return(RedirectToAction("SetPasswordConfirmation", "Account")); } AddErrors(result); return(View()); }
/// <summary> /// Upload background image /// </summary> /// <returns>Succsess or error view</returns> public ActionResult BackgroundUpload() { if (Request.Files.Count > 0) { try { var backgroundObj = new DbTables.BackgroundImage(); var background = _context.BackgroundImage.ToList(); if (background.Any()) { backgroundObj = background.First(); } else { backgroundObj = new DbTables.BackgroundImage { Enabeled = true, Image = new DbTables.File() }; _context.BackgroundImage.Add(backgroundObj); } // Get all files from Request object var files = Request.Files; for (var i = 0; i < files.Count; i++) { var file = files[i]; var fileUpload = new DbTables.File { FileName = Path.GetFileName(file.FileName), ContentType = file.ContentType, Temporary = false, FileType = DbTables.FileType.BackgroundImage }; using (var reader = new BinaryReader(file.InputStream)) { fileUpload.Content = reader.ReadBytes(file.ContentLength); } _context.Files.Add(fileUpload); backgroundObj.Image = fileUpload; } _context.SaveChanges(); ViewBag.Success = "Filen(e) ble sukksessfult lastet opp"; return(PartialView("_BackgroundImagePartial", backgroundObj)); } catch (Exception ex) { ViewBag.Error = "Error: " + ex.Message; var backgrounderr = new DbTables.BackgroundImage(); var backgroundl = _context.BackgroundImage.ToList(); if (backgroundl.Any()) { backgrounderr = backgroundl.First(); } return(PartialView("_BackgroundImagePartial", backgrounderr)); } } ViewBag.Error = "Ingen fil valgt"; var backgroundError = new DbTables.BackgroundImage(); var backgroundL = _context.BackgroundImage.ToList(); if (backgroundL.Any()) { backgroundError = backgroundL.First(); } return(PartialView("_BackgroundImagePartial", backgroundError)); }
// 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)); }
// // GET: /Manage/Index public async Task <ActionResult> Index(ManageMessageId?message) { 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;"; } } ViewBag.StatusMessage = message == ManageMessageId.ChangePasswordSuccess ? "Ditt passord har blitt endred." : message == ManageMessageId.SetPasswordSuccess ? "Ditt passord har blitt sett." : message == ManageMessageId.SetTwoFactorSuccess ? "Your two-factor authentication provider has been set." : message == ManageMessageId.Error ? "En feil oppstod." : message == ManageMessageId.AddPhoneSuccess ? "Your phone number was added." : message == ManageMessageId.RemovePhoneSuccess ? "Your phone number was removed." : ""; var userId = User.Identity.GetUserId(); var indexModel = new IndexViewModel { HasPassword = HasPassword(), PhoneNumber = await UserManager.GetPhoneNumberAsync(userId), TwoFactor = await UserManager.GetTwoFactorEnabledAsync(userId), Logins = await UserManager.GetLoginsAsync(userId), BrowserRemembered = await AuthenticationManager.TwoFactorBrowserRememberedAsync(userId) }; var user = _context.Users.Find(userId); var ProfileImage = new DbTables.File(); var pictures = user.Pictures.Where(s => s.FileType == DbTables.FileType.Profile); if (pictures.Any()) { ProfileImage = pictures.First(); } var profileModel = new changeProfileModel //change profile user info { Fname = user.Fname, Lname = user.Lname, City = user.Adress.City, StreetAdress = user.Adress.StreetAdress, PostCode = user.Adress.PostCode, State = user.Adress.County, Phone = user.Phone, Id = user.Id, File = ProfileImage, BirthNumber = user.BirthNumber }; var model = new ProfileViewModel { Index = indexModel, Profile = profileModel }; return(View(model)); //return view with updated values }