Пример #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 Edit(int id, FormCollection form)
        {
            using (var context = new ContentStorage())
            {
                var content = context.Content.Where(c => c.Id == id).First();
                TryUpdateModel(content, new[]
                                            {
                                                "Name",
                                                "ContentModel",
                                                "Title",
                                                "MenuTitle",
                                                "PageTitle",
                                                "SortOrder",
                                                "SeoDescription",
                                                "SeoKeywords"
                                            });
                content.Text = HttpUtility.HtmlDecode(form["Text"]);
                content.WeatherScript = HttpUtility.HtmlDecode(form["WeatherScript"]);
                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
 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 = "" });
 }
Пример #4
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 = "" });
 }
Пример #5
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 = "" });
 }
Пример #6
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 = "" });
        }
Пример #7
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");
 }
Пример #8
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 = "" });
 }
Пример #9
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 = ""});
            }
        }
Пример #10
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" });
        }
Пример #11
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" });
        }
Пример #12
0
        public ActionResult Create(FormCollection form, HttpPostedFileBase fileUpload)
        {
            using (var context = new ContentStorage())
            {
                if (fileUpload != null)
                {
                    string fileName = IOHelper.GetUniqueFileName("~/Content/Banners", fileUpload.FileName);
                    string filePath = Server.MapPath("~/Content/Banners");
                    filePath = Path.Combine(filePath, fileName);
                    fileUpload.SaveAs(filePath);

                    var banner = new Banner();
                    TryUpdateModel(banner, new[] { "Price", "Title", "Title2", "ContentName" });
                    banner.BannerType = Convert.ToInt32(form["BannerType"]);
                    banner.ImageSource = fileName;
                    context.AddToBanner(banner);
                    context.SaveChanges();
                }

            }
            return RedirectToAction("Index", "Banner", new { Area = "Admin" });
        }
Пример #13
0
        public ActionResult Create(FormCollection form, HttpPostedFileBase fileUpload)
        {
            using (var context = new ContentStorage())
            {
                if (fileUpload != null)
                {
                    string fileName = IOHelper.GetUniqueFileName("~/Content/ActualTours", fileUpload.FileName);
                    string filePath = Server.MapPath("~/Content/ActualTours");
                    filePath = Path.Combine(filePath, fileName);
                    fileUpload.SaveAs(filePath);

                    var tour = new ActualTours();
                    TryUpdateModel(tour, new[] { "Price", "Title", "Description", "Sign1", "Sign2", "Sign3", "Sign4", "Sign5" });
                    tour.Text = HttpUtility.HtmlDecode(form["Text"]);
                    tour.ImageSource = fileName;
                    context.AddToActualTours(tour);
                    context.SaveChanges();
                }

            }
            return RedirectToAction("Index", "Home", new { Area = "", id = "" });
        }
Пример #14
0
        public ActionResult Add(FormCollection form)
        {
            using (var context = new ContentStorage())
            {
                var article = new Article();
                TryUpdateModel(article, new[] { "Title", "Date" });
                article.Text = HttpUtility.HtmlDecode(form["Text"]);
                context.AddToArticle(article);
                context.SaveChanges();

                var mailText = article.Text.Replace("src=\"", "src=\"http://havila-travel.com/");
                var customers = context.Customers.Where(c=>c.IsActive==1).ToList();
                foreach (var customer in customers)
                {
                    mailText += "<br/><br/> Для того, чтобы отписаться от рассылке перейдите пожалуйста по следующей ссылке <br/>";
                    mailText += "<a href=\"http://havila-travel.com/unsubscribe/" + customer.Id + "\">http://havila-travel.com/unsubscribe/" + customer.Id + "</a>";
                    MailHelper.SendMessage(new MailAddress(customer.Email), mailText, "Рассылка Havila-Travel", true);
                }

            }
            return RedirectToAction("Index", "Articles", new { Area = "" });
        }
Пример #15
0
        public ActionResult Edit(Banner model, FormCollection form, HttpPostedFileBase fileUpload)
        {
            using (var context = new ContentStorage())
            {
                var banner = context.Banner.Where(b => b.Id == model.Id).First();
                string fileName = banner.ImageSource;

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

                    fileName = IOHelper.GetUniqueFileName("~/Content/Banners", fileUpload.FileName);
                    string filePath = Server.MapPath("~/Content/Banners");
                    filePath = Path.Combine(filePath, fileName);
                    fileUpload.SaveAs(filePath);
                }
                TryUpdateModel(banner, new[] { "Price", "Title", "Title2", "ContentName" });
                banner.BannerType = Convert.ToInt32(form["BannerType"]);
                banner.ImageSource = fileName;
                context.SaveChanges();
            }
            return RedirectToAction("Index", "Banner", new { Area = "Admin" });
        }
Пример #16
0
        public ActionResult SaveSubscribersSettings(FormCollection form)
        {
            using (var context = new ContentStorage())
            {
                PostData agentsData = form.ProcessPostData("agent");
                PostData touristData = form.ProcessPostData("tourist");

                int[] agentIds =
                    agentsData.Where(d => bool.Parse(d.Value["agent"])).Select(id => Convert.ToInt32(id.Key)).ToArray();
                int[] touristIds =
                    touristData.Where(d => bool.Parse(d.Value["tourist"])).Select(id => Convert.ToInt32(id.Key)).ToArray
                        ();

                var customers = context.Customers.ToList();
                var agents =
                    (from customer in customers from id in agentIds where customer.Id == id select customer).ToList();
                var tourists =
                    (from customer in customers from id in touristIds where customer.Id == id select customer).ToList();
                IEnumerable<Customers> all = agents.Concat(tourists);


                foreach (var customer in customers)
                {
                    customer.IsActive = 0;
                }

                foreach (var customer in customers)
                {
                    if (agentIds.Contains(Convert.ToInt32(customer.Id)) || touristIds.Contains(Convert.ToInt32(customer.Id)))
                        customer.IsActive = 1;
                }
                context.SaveChanges();
            }
            return RedirectToAction("SubscribersList");
        }
Пример #17
0
        public ActionResult DeleteSubscriber(int id)
        {
            using (var context = new ContentStorage())
            {
                var subscriber = context.Customers.First(c => c.Id == id);
                context.DeleteObject(subscriber);
                context.SaveChanges();
            }

            return RedirectToAction("Subscribers");
        }
Пример #18
0
 public ActionResult EditSubscriber(int id, FormCollection form)
 {
     using (var context = new ContentStorage())
     {
         var subscriber = context.Customers.First(c => c.Id == id);
         TryUpdateModel(subscriber, new[] { "Name", "Email", "SubscribeType" });
         context.SaveChanges();
         return RedirectToAction("Subscribers", "Subscribe");
     }
 }
Пример #19
0
 public ActionResult Delete(int id)
 {
     using (var context = new ContentStorage())
     {
         var bellboy = context.Bellboy.Where(b => b.Id == id).First();
         IOHelper.DeleteFile("~/Content/Bellboy", bellboy.ImageSource);
         context.DeleteObject(bellboy);
         context.SaveChanges();
     }
     return RedirectToAction("Index", "Bellboy", new { Area = "Admin" });
 }
Пример #20
0
        public ActionResult Delete(int id)
        {
            using (var context = new ContentStorage())
            {
                var accordion = context.Accordion.Include("Content").Include("AccordionImages").Where(a => a.Id == id).First();
                var content = accordion.Content;

                while (accordion.AccordionImages.Any())
                {
                    var image = accordion.AccordionImages.First();
                    IOHelper.DeleteFile("~/Content/Photos", image.ImageSource);
                    context.DeleteObject(image);
                }
                
                context.DeleteObject(accordion);
                
                context.SaveChanges();
                if (content.PlaceKind > 0)
                    return RedirectToAction("Index", "Place", new { id = content.Name, area = "" });
                return RedirectToAction("Index", "Home", new { id = content.Name, area = "" });
            }

        }
Пример #21
0
 public ActionResult AddRegion(FormCollection form, int placeKind)
 {
     using (var context = new ContentStorage())
     {
         var content = new Content { PlaceKind = placeKind, ContentLevel = 1 };
         TryUpdateModel(content,
                        new[]{
                                "Name", 
                                "Title", 
                                "MenuTitle", 
                                "PageTitle", 
                                "SortOrder", 
                                "SeoDescription",
                                "SeoKeywords"
                        });
         content.Text = HttpUtility.HtmlDecode(form["Text"]);
         context.AddToContent(content);
         context.SaveChanges();
         return RedirectToAction("Index", "Home", new { id = content.Name, area = "" });
     }
 }
Пример #22
0
        public ActionResult AddPhoto(int parentId, IEnumerable<HttpPostedFileBase> fileUpload, IList<string> fileTitles )
        {
            using (var context = new ContentStorage())
            {
                var accordion = context.Accordion.Include("Content").Where(a => a.Id == parentId).First();


                int titleIndex = 0;
                foreach (var file in fileUpload)
                {
                    
                    if (file == null) continue;

                    string fileName = IOHelper.GetUniqueFileName("~/Content/Photos", file.FileName);
                    string filePath = Server.MapPath("~/Content/Photos");
                    filePath = Path.Combine(filePath, fileName);
                    file.SaveAs(filePath);

                    context.AddToAccordionImage(new AccordionImage
                                                    {
                                                        ImageSource = fileName,
                                                        Accordion = accordion,
                                                        Title = fileTitles[titleIndex]
                                                    });
                    context.SaveChanges();
                    titleIndex++;
                }


                if (accordion.Content.PlaceKind > 0)
                    return RedirectToAction("Index", "Place", new { id = accordion.Content.Name, area = "" });
                return RedirectToAction("Index", "Home", new {id = accordion.Content.Name, area = ""});
            }
        }
Пример #23
0
        public ActionResult Delete(int id)
        {
            using (var context = new ContentStorage())
            {
                var content = context.Content.Include("Children").Where(c => c.Id == id).First();

                while (content.Children.Any())
                {
                    var child = content.Children.First();
                    child.Accordions.Load();
                    while (child.Accordions.Any())
                    {
                        var accordion = child.Accordions.First();
                        accordion.AccordionImages.Load();
                        while (accordion.AccordionImages.Any())
                        {
                            var image = accordion.AccordionImages.First();
                            IOHelper.DeleteFile("~/Content/Photos", image.ImageSource);
                            context.DeleteObject(image);
                        }
                        context.DeleteObject(accordion);
                    }
                    context.DeleteObject(child);
                }
                context.DeleteObject(content);
                context.SaveChanges();
            }
            return RedirectToAction("Index", "Home", new { area = "" , id="countries"});
        }
Пример #24
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 = "" });
 }