Exemplo n.º 1
0
        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));
        }
Exemplo n.º 2
0
        /// <summary>
        ///     upload terms of use document
        /// </summary>
        /// <returns>Succsess or failure partial view</returns>
        public ActionResult TermsUpload()
        {
            if (Request.Files.Count > 0) //check that there are actually files in the request
            {
                try
                {
                    var Terms     = new DbTables.TermsOfUse();
                    var TermsList = _context.TermsOfUse.ToList();
                    if (TermsList.Any()) //if it exist already, get it
                    {
                        Terms = TermsList.First();
                    }
                    //  Get all files from Request object
                    var files = Request.Files;
                    for (var i = 0; i < files.Count; i++) //get the files object
                    {
                        var file = files[i];
                        if (Terms.Id == 0) //add the file, it does not exist
                        {
                            var TermsFile = new DbTables.File
                            {
                                FileName    = Path.GetFileName(file.FileName),
                                FileType    = DbTables.FileType.PDF,
                                ContentType = file.ContentType,
                                Temporary   = false
                            };

                            using (var reader = new BinaryReader(file.InputStream))
                            {
                                TermsFile.Content = reader.ReadBytes(file.ContentLength);
                            }

                            _context.Files.Add(TermsFile);
                            Terms.Terms    = TermsFile;
                            Terms.Enabeled = true;
                            _context.TermsOfUse.Add(Terms);
                            _context.SaveChanges();
                        }
                        else
                        {
                            var TermsFile = Terms.Terms; //it exists, just change values
                            TermsFile.FileName    = Path.GetFileName(file.FileName);
                            TermsFile.FileType    = DbTables.FileType.PDF;
                            TermsFile.ContentType = file.ContentType;

                            using (var reader = new BinaryReader(file.InputStream))
                            {
                                TermsFile.Content = reader.ReadBytes(file.ContentLength);
                            }
                            _context.SaveChanges();
                        }
                    }
                    ViewBag.Success = "Filen ble sukksessfult lastet opp";
                    return(PartialView("_TermsOfUserPartial", Terms));
                }
                catch (Exception ex)
                {
                    ViewBag.Error = "Error: " + ex.Message;
                    var Terms     = new DbTables.TermsOfUse();
                    var TermsList = _context.TermsOfUse.ToList();
                    if (TermsList.Any())
                    {
                        Terms = TermsList.First();
                    }
                    return(PartialView("_TermsOfUserPartial", Terms));
                }
            }
            ViewBag.Error = "Ingen fil valgt";
            var TermsError     = new DbTables.TermsOfUse();
            var TermsListError = _context.TermsOfUse.ToList();

            if (TermsListError.Any())
            {
                TermsError = TermsListError.First();
            }
            return(PartialView("_TermsOfUserPartial", TermsError));
        }
Exemplo n.º 3
0
        // 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));
        }