예제 #1
0
        public IActionResult DeleteTour(int id)
        {
            Tour tour = _tourRepository.GetTourById(id);

            if (tour != null)
            {
                ImageHelper.DeleteImage(_hostingEnvironment, tour.Img);
                _tourRepository.DeleteTour(tour);
            }
            return(Redirect("/Home/Index"));
        }
예제 #2
0
        public IActionResult Details(int id)
        {
            var tour = _tourRepository.GetTourById(id);

            if (tour == null)
            {
                return(NotFound());
            }
            return(View(tour));
        }
예제 #3
0
        public IActionResult SuccessOrder(OrderPaymentViewModel model)
        {
            var str     = HttpContext.Session.GetString("Order");
            var data    = JsonConvert.DeserializeObject <OrderSubmitViewModel>(str);
            var webRoot = _env.WebRootPath;

            var pathToFile = _env.WebRootPath
                             + Path.DirectorySeparatorChar.ToString()
                             + "Templates"
                             + Path.DirectorySeparatorChar.ToString()
                             + "EmailTemplate"
                             + Path.DirectorySeparatorChar.ToString()
                             + "SendOrder.html";

            var subject = "Thank for your order.";

            var builder = new BodyBuilder();

            using (StreamReader SourceReader = System.IO.File.OpenText(pathToFile))
            {
                builder.HtmlBody = SourceReader.ReadToEnd();
            }
            var    tour        = _tourRepository.GetTourById(data.IdTour);
            string messageBody = string.Format(builder.HtmlBody,
                                               subject,
                                               String.Format("{0:dddd, d MMMM yyyy}", DateTime.Now),
                                               data.Firstname + " " + data.Lastname,
                                               data.Email,
                                               tour.Name,
                                               tour.Countries,
                                               tour.DepartureTown,
                                               tour.Period,
                                               String.Format("{0:dddd, d MMMM yyyy}", data.DateDeparture),
                                               model.CardHolder,
                                               model.CardNumber
                                               );

            _emailSender.SendEmailAsync(data.Email, subject, messageBody);
            return(View());
        }
예제 #4
0
        public IActionResult Tour(int id)
        {
            var tour = _tourRepository.GetTourById(id);

            return(View(tour));
        }