Пример #1
0
        public ActionResult Subscribe(FormCollection form)
        {

            var alreadySubscribed = false;
            using (var context = new ContentStorage())
            {

                var subscriber = new Customers {Guid = Guid.NewGuid().ToString()};
                TryUpdateModel(subscriber, new[] { "Name", "Email", "SubscribeType" });

                var email = form["Email"];
                byte subscrType = Convert.ToByte(form["SubscribeType"]);

                var existedEmail = context.Customers.FirstOrDefault(c => c.Email == email && c.SubscribeType == subscrType);
                if (existedEmail == null)
                {
                    context.AddToCustomers(subscriber);
                    context.SaveChanges();
                }
                else
                {
                    alreadySubscribed = true;
                }
            }

            if (!string.IsNullOrEmpty(form["redirectUrl"]) && form["redirectUrl"] == "sbscrList")
                return RedirectToAction("Subscribers", "Subscribe");

            return RedirectToAction(alreadySubscribed ? "AlreadySubscribed" : "ThankYou");
        }
Пример #2
0
        public ActionResult AddSubmenu(int parentId, FormCollection form)
        {
            using (var context = new ContentStorage())
            {
                var parentContent = context.Content.Where(c => c.Id == parentId).First();
                var content = new Content();
                TryUpdateModel(content, new[]
                                            {
                                                "Name",
                                                "ContentModel",
                                                "Title",
                                                "MenuTitle",
                                                "PageTitle",
                                                "SortOrder",
                                                "SeoDescription",
                                                "SeoKeywords",
                                                //"ContentType",
                                                "ContentLevel",
                                                "PlaceKind"
                                            });
                content.Text = HttpUtility.HtmlDecode(form["Text"]);
                content.WeatherScript = HttpUtility.HtmlDecode(form["WeatherScript"]);
                content.Parent = parentContent;
                context.AddToContent(content);
                context.SaveChanges();

                if (content.PlaceKind > 0)
                    return RedirectToAction("Index", "Place", new { id = content.Name, area = "" });

                return RedirectToAction("Index", "Home", new { id = content.Name, area = "" });
            }
        }
Пример #3
0
        //
        // GET: /Place/

        //private List<MenuItem> _placesMap = new List<MenuItem>();

        public ActionResult Index(string id, bool? showSpa, bool? showPlacesReview, bool? showPrices, int? palceKind, int? placeKind)
        {
            using (var context = new ContentStorage())
            {
                if (string.IsNullOrEmpty(id))
                    id = "Countries";
                if (placeKind.HasValue)
                {
                    if (placeKind.Value == 11)
                    {
                        id = "Spa";
                        //WebSession.CurrentMenuHighlight = CurrentMenuHighlight.Spa;
                    }
                    else
                    {
                        //WebSession.CurrentMenuHighlight = CurrentMenuHighlight.Country;
                    }
                    WebSession.PlaceKind = (PlaceKind)placeKind.Value;
                }
                PlaceViewModel model = new PlaceViewModel(id, context, showSpa, showPlacesReview, showPrices);
                ViewBag.PageTitle = model.Content.PageTitle;
                ViewBag.SeoDescription = model.Content.SeoDescription;
                ViewBag.SeoKeywords = model.Content.SeoKeywords;
                ViewBag.CurrentContentId = model.CurrentContentId;

                ViewBag.SelectedCountryItem = model.Content.Name;
                ViewBag.PlaceKind = (int)PlaceKind.Region;
                return View(model);
            }
        }
Пример #4
0
 public ActionResult Unsubscribed()
 {
     using (var context = new ContentStorage())
     {
         var model = new SiteViewModel(null, context, false);
         return View(model);
     }
 }
Пример #5
0
 public ActionResult Edit(int id)
 {
     using (var context = new ContentStorage())
     {
         var banner = context.Banner.Where(b => b.Id == id).First();
         return View(banner);
     }
 }
Пример #6
0
 public PartialViewResult GetBellboy()
 {
     using (var context = new ContentStorage())
     {
         var bellboy = context.Bellboy.GetRandomItem();
         return PartialView("Bellboy", bellboy);
     }
 }
Пример #7
0
 public ActionResult Edit(int id)
 {
     using (var context = new ContentStorage())
     {
         var accordion = context.Accordion.Where(a => a.Id == id).First();
         return View(accordion);
     }
 }
Пример #8
0
 public ActionResult Edit(int id)
 {
     using (var context = new ContentStorage())
     {
         var article = context.Article.First(a => a.Id == id);
         return View(article);
     }
 }
Пример #9
0
        //
        // GET: /Admin/Content/

        public ActionResult Edit(int id)
        {
            using (var context = new ContentStorage())
            {
                var content = context.Content.Where(c => c.Id == id).First();
                return View(content);
            }
        }
Пример #10
0
 public ActionResult Edit(int id)
 {
     using (var context = new ContentStorage())
     {
         var template = context.MailTemplate.First(t => t.Id == id);
         return View(template);
     }
 }
Пример #11
0
        //
        // GET: /Admin/Bellboy/

        public ActionResult Index()
        {
            using (var context = new ContentStorage())
            {
                var content = context.Bellboy.ToList();
                return View(content);
            }
        }
Пример #12
0
 public ActionResult Edit(int id)
 {
     using (var context = new ContentStorage())
     {
         var bellboy = context.Bellboy.Where(b => b.Id == id).First();
         return View(bellboy);
     }
 }
Пример #13
0
 public ActionResult TourDetails(int id)
 {
     using (var context = new ContentStorage())
     {
         var tour = context.ActualTours.First(t => t.Id == id);
         return PartialView(tour);
     }
 }
Пример #14
0
 public ActionResult Delete(int id)
 {
     using (var context = new ContentStorage())
     {
         var template = context.MailTemplate.First(t => t.Id == id);
         context.DeleteObject(template);
         context.SaveChanges();
     }
     return RedirectToAction("Subscribers", "Subscribe", new { Area = "" });
 }
Пример #15
0
 public ActionResult Delete(int id)
 {
     using (var context = new ContentStorage())
     {
         var tour = context.ActualTours.First(t => t.Id == id);
         IOHelper.DeleteFile("~/Content/ActualTours", tour.ImageSource);
         context.DeleteObject(tour);
         context.SaveChanges();
     }
     return RedirectToAction("Index", "Home", new { Area = "", id = "" });
 }
Пример #16
0
        public ActionResult Delete(int id)
        {
            using (var context = new ContentStorage())
            {
                var article = context.Article.First(a => a.Id == id);
                context.DeleteObject(article);
                context.SaveChanges();
            }

            return RedirectToAction("Index", "Articles", new { Area = "" });
        }
Пример #17
0
 public ActionResult Edit(int id, FormCollection form)
 {
     using (var context = new ContentStorage())
     {
         var article = context.Article.First(a => a.Id == id);
         TryUpdateModel(article, new[] { "Title", "Date" });
         article.Text = HttpUtility.HtmlDecode(form["Text"]);
         context.SaveChanges();
     }
     return RedirectToAction("Index", "Articles", new { Area = "" });
 }
Пример #18
0
 public ActionResult Edit(int id, FormCollection form)
 {
     using (var context = new ContentStorage())
     {
         var template = context.MailTemplate.First(t => t.Id == id);
         template.Title = form["Title"];
         template.Text = HttpUtility.HtmlDecode(form["Text"]);
         context.SaveChanges();
     }
     return RedirectToAction("Subscribers", "Subscribe", new { Area = "" });
 }
Пример #19
0
 public ActionResult NotFound()
 {
     using (var context = new ContentStorage())
     {
         SiteViewModel model = new SiteViewModel(null, context, true)
                                   {
                                       IsRoot = false
                                   };
         return View(model);
     }
 }
Пример #20
0
 public ActionResult Details(int id)
 {
     using (var context = new ContentStorage())
     {
         var model = new SiteViewModel("articles", context, false)
         {
             Article = context.Article.First(a => a.Id == id)
         };
         ViewBag.PageTitle = model.Article.Title;
         return View(model);
     }
 }
Пример #21
0
 public ActionResult Unsubscribe(string id)
 {
     using (var context = new ContentStorage())
     {
         var customer = context.Customers.FirstOrDefault(c => c.Guid == id);
         if (customer != null)
         {
             context.DeleteObject(customer);
             context.SaveChanges();
         }
     }
     return RedirectToAction("Unsubscribed");
 }
Пример #22
0
 public ActionResult Add(FormCollection form)
 {
     using (var context = new ContentStorage())
     {
         var template = new MailTemplate
                            {
                                Title = form["Title"], 
                                Text = HttpUtility.HtmlDecode(form["Text"])
                            };
         context.AddToMailTemplate(template);
         context.SaveChanges();
     }
     return RedirectToAction("Subscribers", "Subscribe", new { Area = "" });
 }
Пример #23
0
 public ActionResult AddSubmenu(int id, int? placeKind)
 {
     using (var context = new ContentStorage())
     {
         var content = context.Content.Where(c => c.Id == id).First();
         ViewBag.parentId = id;
         return View(new Content
                         {
                             ContentLevel = content.ContentLevel + 1,
                             ContentType = content.ContentType,
                             PlaceKind = placeKind.HasValue ? placeKind.Value : 0
                         });
     }
 }
Пример #24
0
 public ActionResult Index(string id)
 {
     //WebSession.CurrentMenuHighlight = CurrentMenuHighlight.None;
     using (var context = new ContentStorage())
     {
         
         SiteViewModel model = new SiteViewModel(id, context, true);
         ViewBag.PageTitle = model.Content.PageTitle;
         ViewBag.SeoDescription = model.Content.SeoDescription;
         ViewBag.SeoKeywords = model.Content.SeoKeywords;
         ViewBag.CurrentContentId = model.CurrentContentId;
         
         return View(model);
     }
 }
Пример #25
0
        public ActionResult Edit(int id, FormCollection form)
        {
            using (var context = new ContentStorage())
            {
                var accordion = context.Accordion.Include("Content").Where(a => a.Id == id).First();
                var content = accordion.Content;

                TryUpdateModel(accordion, new[] {"Title", "SortOrder"});
                accordion.Text = HttpUtility.HtmlDecode(form["Text"]);

                context.SaveChanges();
                if (content.PlaceKind > 0)
                    return RedirectToAction("Index", "Place", new { id = content.Name, area = "" });
                return RedirectToAction("Index", "Home", new {id = content.Name, area = ""});
            }
        }
Пример #26
0
        public ActionResult Search(string query)
        {
            //WebSession.CurrentMenuHighlight = CurrentMenuHighlight.None;
            using (var context = new ContentStorage())
            {
                SiteViewModel model = new SiteViewModel("countries", context, false)
                                          {
                                              SearchResult = new List<Content>(), 
                                              SearchQuery = query
                                          };

                ViewBag.PageTitle = "Результат поиска";

                if (string.IsNullOrEmpty(query))
                {
                    return View(model);
                }

                query = query.ToLower();

                var contentItems = context.Content.Include("Parent")
                    //.Include("Accordions")
                    .Where(c => c.PlaceKind > 1).ToList();
                foreach (var content in contentItems)
                {
                    content.Text = HttpUtility.HtmlDecode(content.Text);
                    content.Text = Regex.Replace(content.Text, @"<[^>]+>", String.Empty).Replace("\r", String.Empty).Replace("\n", String.Empty).Replace("\t", String.Empty);
                    int strLength = content.Text.Length;
                    if (strLength > 500) strLength = 500;
                    content.Text = content.Text.Substring(0, strLength);
                    //foreach (var accordion in content.Accordions)
                    //{
                    //    accordion.AccordionImages.Load();
                    //}

                    if (content.Title != null && content.Title.ToLower().Contains(query) 
                        || content.MenuTitle != null && content.MenuTitle.ToLower().Contains(query) 
                        || content.Text != null && content.Text.ToLower().Contains(query))
                        model.SearchResult.Add(content);

                }
                return View(model);
            }
        }
Пример #27
0
        public PlaceViewModel(string id, ContentStorage context, bool? showSpa, bool? showPlacesReview, bool? showPrices)
            : base(id, context,false, true)
        {
            
            _showSpa = showSpa;
            _showPlacesReview = showPlacesReview;
            _showPrices = showPrices;

            PlacesMap = FillPlacesMap(Content, Context);

            RegionsAndCountries = Context.Content.Include("Children").Where(c => c.PlaceKind == (int)WebSession.PlaceKind).ToList();

            Spa = GetSpa();
            PlaceReview = GetPlaceReview();
            PriceTable = GetPriceTable();

            LeftSubMenuItems = GetLeftSubMenuItems();
            PlacesForSelector = GetPlacesForSelector();
            ResortsForSelector = GetResortsSelector();
        }
Пример #28
0
        //
        // GET: /Admin/Validation/

        public JsonResult IsNameAvailable(string name)
        {
            using (var context = new ContentStorage())
            {
                //Match match = Regex.Match(name, "([a-z]|[A-Z]|[0-9])+");
                Match match = Regex.Match(name, @"^[a-z0-9_]{1,100}$");

                if (!match.Success)
                {
                    return Json("Введите только маленькие латинские символы и цифры без пробелов!", JsonRequestBehavior.AllowGet);
                }

                var content = context.Content.FirstOrDefault(c => c.Name == name);
                if (content != null)
                {
                    return Json("Страница с таким именем уже существует, введите другое имя!", JsonRequestBehavior.AllowGet);
                }
            }

            return Json(true, JsonRequestBehavior.AllowGet);
        }
Пример #29
0
        public ActionResult Edit(Banner model, FormCollection form, HttpPostedFileBase fileUpload)
        {
            using (var context = new ContentStorage())
            {
                var bellboy = context.Bellboy.Where(b => b.Id == model.Id).First();
                string fileName = bellboy.ImageSource;

                if (fileUpload != null)
                {
                    IOHelper.DeleteFile("~/Content/Bellboy", bellboy.ImageSource);

                    fileName = IOHelper.GetUniqueFileName("~/Content/Bellboy", fileUpload.FileName);
                    string filePath = Server.MapPath("~/Content/Bellboy");
                    filePath = Path.Combine(filePath, fileName);
                    fileUpload.SaveAs(filePath);
                }
                TryUpdateModel(bellboy, new[] { "TopText", "TopLink", "BottomText", "BottomLink" });
                bellboy.ImageSource = fileName;
                context.SaveChanges();
            }
            return RedirectToAction("Index", "Bellboy", new { Area = "Admin" });
        }
Пример #30
0
        public ActionResult Create(FormCollection form, HttpPostedFileBase fileUpload)
        {
            using (var context = new ContentStorage())
            {
                if (fileUpload != null)
                {
                    
                    string fileName = IOHelper.GetUniqueFileName("~/Content/Bellboy", fileUpload.FileName);
                    string filePath = Server.MapPath("~/Content/Bellboy");
                    filePath = Path.Combine(filePath, fileName);
                    fileUpload.SaveAs(filePath);
                    
                    var bellboy = new Bellboy();
                    TryUpdateModel(bellboy, new[] { "TopText", "TopLink", "BottomText", "BottomLink" });
                    bellboy.ImageSource = fileName;
                    context.AddToBellboy(bellboy);
                    context.SaveChanges();
                }

            }
            return RedirectToAction("Index", "Bellboy", new { Area = "Admin" });
        }