Beispiel #1
0
        public ActionResult Get(int id = -1)
        {
            if (Session["IsAuthenticated"] == null)
            {
                return(Redirect("/Admin/Index"));
            }
            var vm = new BatturViewModel();

            if (id > -1)
            {
                vm.ErNy       = false;
                vm.Battur     = this._unit.Batturer.GetById(id);
                vm.Kategorier = new List <Kategori>();


                if (vm.Battur != null)
                {
                    int batturid = vm.Battur.BatturId;

                    if (vm.Battur.Kategorier != null)
                    {
                        foreach (var bk in vm.Battur.Kategorier)
                        {
                            var kategori = this._unit.Kategorier.GetById(bk.KategoriId);
                            if (kategori != null)
                            {
                                vm.Kategorier.Add((Kategori)kategori);
                            }
                        }
                    }

                    vm.Bilder = new List <BatturImage>();
                    var tempImages = this._unit.BatturImages.GetByBatturId(batturid);

                    foreach (var temp in tempImages)
                    {
                        var image = new BatturImage
                        {
                            ImageFile    = Config.BatturerImagesUrlPrefix + temp.ImageFile,
                            ImageId      = temp.ImageId,
                            BatturId     = temp.BatturId,
                            ErHovedbilde = temp.ErHovedbilde
                        };
                        vm.Bilder.Add(image);

                        if (temp.ErHovedbilde)
                        {
                            vm.Hovedbilde = image.ImageId.ToString();
                        }
                    }
                    ;
                    vm.Battur.Beskrivelse = vm.Battur.Beskrivelse.Replace("\n", "");
                }
                return(View("EndreBattur", vm));
            }
            return(View("Error"));
        }
Beispiel #2
0
        //[Authorize]
        public ActionResult NyBattur()
        {
            if (Session["IsAuthenticated"] == null)
            {
                return(Redirect("/Admin/Index"));
            }
            var vm = new BatturViewModel();

            vm.ErNy              = true;
            vm.Battur            = new Battur();
            vm.Batturer          = new List <Battur>();
            vm.Battur.Kategorier = new List <Kategori>();
            vm.Hovedbilde        = "";

            return(View("EndreBattur", vm));
        }
Beispiel #3
0
        public ActionResult BatturEngelsk(int id, string seoName)
        {
            var vm = new BatturViewModel();

            vm.ErNy = false;
            var batturer = this._unit.Batturer.GetAll().ToList();

            vm.Batturer = batturer;

            vm.Battur = this._unit.Batturer.GetById(id);

            if (vm.Battur != null)
            {
                int batturid = vm.Battur.BatturId;

                vm.Bilder = new List <BatturImage>();

                var tempImages = this._unit.BatturImages.GetByBatturId(batturid);

                foreach (var temp in tempImages)
                {
                    var image = new BatturImage
                    {
                        ImageFile    = Config.BatturerImagesUrlPrefix + temp.ImageFile,
                        ImageId      = temp.ImageId,
                        BatturId     = temp.BatturId,
                        ErHovedbilde = temp.ErHovedbilde
                    };
                    vm.Bilder.Add(image);

                    if (temp.ErHovedbilde)
                    {
                        vm.Hovedbilde = Config.BatturerImagesFolderPath + temp.ImageFile;
                    }
                }
                ;

                vm.Pris = (Config.Timepris * vm.Battur.MinimumTid).ToString();


                var neste   = 0;
                var forrige = 0;

                if (batturer.Count > 1)
                {
                    var index = batturer.IndexOf(vm.Battur);

                    if (index == (batturer.Count - 1))
                    {
                        neste = 0;
                    }
                    else
                    {
                        neste = index + 1;
                    }

                    if (index == 0)
                    {
                        forrige = batturer.Count - 1;
                    }
                    else
                    {
                        forrige = index - 1;
                    }
                }
                else
                {
                    neste   = batturid;
                    forrige = batturid;
                }
                vm.NesteBattur   = batturer.ElementAt(neste).BatturId;
                vm.ForrigeBattur = batturer.ElementAt(forrige).BatturId;

                //Lager seo-vennlige linker
                var seo = "sightseeing-in-oslofjorden-Oslo-to-" + vm.Battur.TilSted;
                if (seoName != Config.SeoName(seo))
                {
                    return(RedirectToActionPermanent("BatturEngelsk", new { id = id, seoName = Config.SeoName(seo) }));
                }

                return(View("BatturEngelsk", vm));
            }

            return(View("Error"));
        }
Beispiel #4
0
        public ActionResult Battur(int id, string seoName)
        {
            var vm = new BatturViewModel();

            vm.ErNy = false;
            var batturer = this._unit.Batturer.GetAll().ToList();

            vm.Batturer   = batturer;
            vm.Kategorier = this._unit.Kategorier.GetAll().ToList();

            vm.Battur = this._unit.Batturer.GetById(id);

            if (vm.Battur != null)
            {
                int batturid = vm.Battur.BatturId;

                var batturKategorier = this._unit.BatturKategorier.GetByBatturId(batturid);

                foreach (var batKat in batturKategorier)
                {
                    var kategori = this._unit.Kategorier.GetById(batKat.KategoriId);
                    vm.Kategorier.Add(kategori);
                }

                vm.Bilder = new List <BatturImage>();

                var tempImages = this._unit.BatturImages.GetByBatturId(batturid);

                foreach (var temp in tempImages)
                {
                    var image = new BatturImage
                    {
                        ImageFile    = Config.BatturerImagesUrlPrefix + temp.ImageFile,
                        ImageId      = temp.ImageId,
                        BatturId     = temp.BatturId,
                        ErHovedbilde = temp.ErHovedbilde
                    };
                    vm.Bilder.Add(image);

                    if (temp.ErHovedbilde)
                    {
                        vm.Hovedbilde = Config.BatturerImagesFolderPath + temp.ImageFile;
                    }
                }
                ;

                var neste   = 0;
                var forrige = 0;

                if (batturer.Count > 1)
                {
                    var index = batturer.IndexOf(vm.Battur);

                    if (index == (batturer.Count - 1))
                    {
                        neste = 0;
                    }
                    else
                    {
                        neste = index + 1;
                    }

                    if (index == 0)
                    {
                        forrige = batturer.Count - 1;
                    }
                    else
                    {
                        forrige = index - 1;
                    }
                }
                else
                {
                    neste   = batturid;
                    forrige = batturid;
                }

                vm.NesteBattur   = batturer.ElementAt(neste).BatturId;
                vm.ForrigeBattur = batturer.ElementAt(forrige).BatturId;


                //Lager seo-vennlige linker
                //var seo = vm.Kategorier[0].KategoriNavn + "-båttur-i-oslofjorden-" + vm.Battur.TilSted;
                var seo = "båttur-oslo-" + vm.Battur.TilSted;
                if (seoName != Config.SeoName(seo))
                {
                    return(RedirectToActionPermanent("Battur", new { id = id, seoName = Config.SeoName(seo) }));
                }


                return(View("Battur", vm));
            }

            return(View("Error"));


            //foreach (var m in valgtBattur.BatturKategorier)
            //{
            //    var q = this._unit.Kategorier.GetById(m.KategoriID);
            //    kat.Add(q);
            //};
        }