Exemplo n.º 1
0
        public ActionResult ListTours(string slug, string item, int?page, int?pageSize)
        {
            using (var db = new MyDbDataContext())
            {
                Menu menu = db.Menus.FirstOrDefault(x => x.Alias == slug);
                ViewBag.slug = slug;
                ViewBag.Menu = menu;
                int pagenumber = page ?? 1;
                int pagesize   = pageSize ?? 9;
                List <ShowObject> _listActivities = CommentController.GetToursActivities(menu.ID);

                switch (item)
                {
                case "0":
                    _listActivities = _listActivities.OrderBy(x => x.ID).ToList();
                    break;

                case "1":
                    _listActivities = _listActivities.OrderBy(x => x.Price).ToList();
                    break;

                case "2":
                    _listActivities = _listActivities.OrderByDescending(x => x.Price).ToList();
                    break;

                default:
                    break;
                }
                IPagedList <ShowObject> _list = _listActivities.ToPagedList(pagenumber, pagesize);

                return(View("Tour/SpecialTour", _list));
            }
        }
Exemplo n.º 2
0
 public JsonResult LoadDataReview(int pageNumber, int menuID, int ID)
 {
     using (var db = new MyDbDataContext())
     {
         var lst  = CommentController.GetListReview(menuID, ID);
         var data = lst.Select(a => new
         {
             a.FullName,
             a.ProfileImages,
             TimeReview = a.TimeReview.ToString("dd/MM/yyy"),
             a.KindOfTrip,
             a.UseService,
             rate   = new int[a.Point],
             unrate = new int[5 - a.Point],
             a.Title,
             a.Content,
             a.ItineraryPoint,
             a.FoodDrinkPoint,
             a.AccomodationsPoint,
             a.GuidePoint,
             a.ActivityPoint
         }).Take(pageNumber).ToList();
         if (pageNumber > data.Count() + 5)
         {
             return(Json(new { status = false, data = data }));
         }
         return(Json(new { status = true, data = data }));
     }
 }
Exemplo n.º 3
0
        public ActionResult SubmitContact(Contact model)
        {
            model.CreateDate = DateTime.Now;

            using (var db = new MyDbDataContext())
            {
                model.CreateDate = DateTime.Now;
                db.Contacts.InsertOnSubmit(model);
                db.SubmitChanges();

                SendEmail sendEmail =
                    db.SendEmails.FirstOrDefault(
                        a => a.Type == TypeSendEmail.Contact);
                Hotel hotel = CommentController.DetailHotel(Request.Cookies["LanguageID"].Value);

                sendEmail.Title = sendEmail.Title.Replace("{NameHotel}", hotel.Name);
                string content = sendEmail.Content;
                content = content.Replace("{FullName}", model.FullName);
                content = content.Replace("{Tel}", model.Tel);
                content = content.Replace("{Email}", model.Email);
                content = content.Replace("{Request}", model.Request);
                content = content.Replace("{NameHotel}", hotel.Name);
                content = content.Replace("{TelHotel}", hotel.Tel);
                content = content.Replace("{EmailHotel}", hotel.Email);
                content = content.Replace("{AddressHotel}", hotel.Address);
                content = content.Replace("{Website}", hotel.Website);

                MailHelper.SendMail(model.Email, sendEmail.Title, content);
                MailHelper.SendMail("*****@*****.**", hotel.Name + " Contact of " + model.FullName, content);
                return(Redirect("/Contact/Messages?status=success"));
            }
        }
Exemplo n.º 4
0
        public ActionResult LisTour(string alias, object idSub, int?page)
        {
            if (idSub.ToString() != "System.Object")
            {
                int idTour;
                int.TryParse(idSub.ToString(), out idTour);
                DetailTour detailTour = CommentController.Detail_Tour(idTour);
                ViewBag.MetaTitle       = detailTour.Tour.MetaTitle ?? detailTour.Tour.Title;
                ViewBag.MetaDesctiption = detailTour.Tour.MetaDescription ?? detailTour.Tour.Title;

                return(View("Tour/DetailTour", detailTour));
            }
            ViewBag.page = page;
            ViewBag.slug = alias;
            return(View("Tour/ListTourByMenuTour"));
        }
Exemplo n.º 5
0
        ////Lấy danh sách tour cấp1
        //public static ListTourRoot GetListAllTour(Menu menu)
        //{
        //    using (var db = new MyDbDataContext())
        //    {

        //        var listMenu = new List<Menu>();
        //        if (menu.ParentId == 0)
        //        {
        //            listMenu =
        //                db.Menus.Where(
        //                    a =>
        //                    a.LanguageId == CurrentSession.LanguageId && a.ParentId != 0 && a.Status &&
        //                    a.TypeMenu == SystemMenuType.TypeTour).ToList();
        //        }
        //        else
        //        {
        //            listMenu= db.Menus.Where(a => a.ParentId == menu.MenuId).ToList();
        //        }

        //        var listTour =
        //            db.Tours.Where(a => a.Status).ToList().Join(listMenu, a => a.MenuId, b => b.MenuId, (a, b) => new ShowObject()
        //                                                                                                    {
        //                                                                                                        Id = a.TourID,
        //                                                                                                        MenuId = b.MenuId,
        //                                                                                                        Alias = a.AliasTour,
        //                                                                                                        Name = a.TitleTour,
        //                                                                                                        Description = a.Description,
        //                                                                                                        Image = a.Image,
        //                                                                                                        MenuAlias = b.AliasMenu
        //                                                                                                    }).ToList();
        //        ListTourRoot listTourRoot = new ListTourRoot
        //                                        {
        //                                            Menus = listMenu,
        //                                            ShowObjects = listTour
        //                                        };
        //        return listTourRoot ?? new ListTourRoot();
        //    }
        //}
        //Danh sách tuor thuộc một chuyên mục
        public static PagingOject GetListTourByMenuTour(int menuId, int page)
        {
            using (var db = new MyDbDataContext())
            {
                var detailMenu = db.Menus.FirstOrDefault(a => a.ID == menuId);
                var listTour   = db.Tours.Where(a => a.MenuID == menuId).Select(a => new ShowObject()
                {
                    ID          = a.ID,
                    MenuID      = a.MenuID,
                    Alias       = a.Alias,
                    Title       = a.Title,
                    Description = a.Description,
                    Image       = a.Image,
                    MenuAlias   = detailMenu.Alias,
                    Address     = a.Address,
                }).ToList();
                //Lấy danh sách và phân trang
                PagingOject pagingOject = CommentController.PagingOnject(listTour, page);
                return(pagingOject);
            }
        }
Exemplo n.º 6
0
        public ActionResult SubmitContact(Contact model, string FirstName, string LastName)
        {
            using (var db = new MyDbDataContext())
            {
                model.CreateDate = DateTime.Now;
                //model.LanguageID = Request.Cookies["LanguageID"].Value;
                model.FullName = FirstName + " " + LastName;
                db.Contacts.InsertOnSubmit(model);
                db.SubmitChanges();

                SendEmail sendEmail =
                    db.SendEmails.FirstOrDefault(
                        a => a.Type == TypeSendEmail.Contact && a.LanguageID == Request.Cookies["LanguageID"].Value);
                Hotel hotel = CommentController.DetailHotel(Request.Cookies["LanguageID"].Value);

                sendEmail.Title = sendEmail.Title.Replace("{NameHotel}", hotel.Name);
                string content = sendEmail.Content;
                content = content.Replace("{FullName}", model.FullName);
                content = content.Replace("{Tel}", model.Tel);
                content = content.Replace("{Email}", model.Email);
                content = content.Replace("{Subject}", model.Subject);
                //content = content.Replace("{NPA}", model.NPA);
                //content = content.Replace("{Sujet}", model.Sujet);
                //content = content.Replace("{Gender}", model.Gender);

                content = content.Replace("{NameHotel}", hotel.Name);
                content = content.Replace("{TelHotel}", hotel.Tel);
                content = content.Replace("{EmailHotel}", hotel.Email);
                content = content.Replace("{AddressHotel}", hotel.Address);
                content = content.Replace("{Website}", hotel.Website);

                MailHelper.SendMail(model.Email, sendEmail.Title, content);
                MailHelper.SendMail(hotel.Email, hotel.Name + " Contact of " + model.FullName, content);
                return(Redirect("/Contact/Messages?status=success"));
            }
        }
Exemplo n.º 7
0
        public ActionResult Index(object aliasMenuSub, object idSub, object aliasSub, int?page, int?pageSize)
        {
            string lan   = Request.Cookies["LanguageID"].Value;
            var    db    = new MyDbDataContext();
            Hotel  hotel = CommentController.DetailHotel(lan);

            ViewBag.MetaTitle       = hotel.MetaTitle;
            ViewBag.MetaDesctiption = hotel.MetaDescription;

            if (aliasMenuSub.ToString() == "System.Object")
            {
                return(View("Index"));
            }

            //if (aliasMenuSub.ToString() == "Search")
            //{
            //    string key = Request.Params["key"];
            //    if (string.IsNullOrEmpty(key))
            //    {
            //        return View("Tour/Search", new List<Tour>());
            //    }
            //    List<ShowObject> listSearch = new List<ShowObject>();
            //    listSearch.AddRange(db.Tours.Where(a => a.Status && a.Title.Contains(key)).OrderBy(a => a.Index).Select(a => new ShowObject() {
            //        ID = a.ID,
            //        Alias = a.Alias,
            //        Description = a.Description,
            //        Image = a.Image,
            //        Index = a.Index,
            //        MenuAlias = a.Menu.Alias,
            //        Title = a.Title,
            //    }).ToList());
            //    listSearch.AddRange(db.Articles.Where(a => a.Status && a.Title.Contains(key)).OrderBy(a => a.Index).Select(a => new ShowObject()
            //    {
            //        ID = a.ID,
            //        Alias = a.Alias,
            //        Description = a.Description,
            //        Image = a.Image,
            //        Index = a.Index,
            //        MenuAlias = a.Menu.Alias,
            //        Title = a.Title,
            //    }).ToList());

            //    return View("Tour/Search", listSearch);
            //}
            if (aliasMenuSub.ToString() == "SelectLanguge")
            {
                Language language = db.Languages.FirstOrDefault(a => a.ID == idSub.ToString());
                if (language == null)
                {
                    language = db.Languages.FirstOrDefault();
                }
                HttpCookie langCookie = Request.Cookies["LanguageID"];
                langCookie.Value   = language.ID;
                langCookie.Expires = DateTime.Now.AddDays(10);
                HttpContext.Response.Cookies.Add(langCookie);
                return(Redirect("/"));
            }
            // xác định menu => tìm ra Kiểu hiển thị của menu
            Menu menu = db.Menus.FirstOrDefault(a => a.Alias == aliasMenuSub.ToString());

            if (menu == null)
            {
                return(View("404"));
            }
            //Seo
            ViewBag.MetaTitle       = menu.MetaTitle ?? menu.Title;
            ViewBag.MetaDesctiption = menu.MetaDescription ?? menu.Title;
            ViewBag.Menu            = menu;

            switch (menu.Type)
            {
            case SystemMenuType.Article:
                goto Trangbaiviet;

            case SystemMenuType.Tour:
                goto TrangTour;

            //case SystemMenuType.Activities:
            //    return LisTour(menu.Alias, idSub, page);
            case SystemMenuType.Activities:
                goto TrangActivities;

            case SystemMenuType.Hotel:
                goto TrangHotel;

            case SystemMenuType.Combo:
                goto TrangCombo;

            case SystemMenuType.Contact:
                return(View("Contact"));

            case SystemMenuType.Aboutus:
                return(View("About"));

            default:
                return(View("Index"));
            }

            #region "Trang bài viết"

Trangbaiviet:
            if (idSub.ToString() != "System.Object")
            {
                int idArticle;
                int.TryParse(idSub.ToString(), out idArticle);
                DetailArticle detailArticle = CommentController.Detail_Article(idArticle);
                ViewBag.MetaTitle       = detailArticle.Article.MetaTitle;
                ViewBag.MetaDesctiption = detailArticle.Article.MetaDescription;
                return(View("Article/DetailArticle", detailArticle));
            }
            //Danh sách bài viết
            List <Article> articles = CommentController.GetArticles();
            if (articles.Count == 1)
            {
                DetailArticle detailArticle = CommentController.Detail_Article(articles[0].ID);
                ViewBag.MetaTitle       = detailArticle.Article.MetaTitle;
                ViewBag.MetaDesctiption = detailArticle.Article.MetaDescription;
                return(View("Article/DetailArticle", detailArticle));
            }
            int pagenumber            = page ?? 1;
            int pagesize              = pageSize ?? 9;
            IPagedList <Article> list = articles.ToPagedList(pagenumber, pagesize);
            return(View("Article/ListArticle", list));

            #endregion "Trang bài viết"


            //trường hợp: Tour

            #region "Kiếu tour"

TrangTour:
            if (idSub.ToString() != "System.Object")
            {
                int idTour;
                int.TryParse(idSub.ToString(), out idTour);
                DetailTour detailTour = CommentController.Detail_Tour(idTour);
                ViewBag.MetaTitle       = detailTour.Tour.MetaTitle ?? detailTour.Tour.Title;
                ViewBag.MetaDesctiption = detailTour.Tour.MetaDescription ?? detailTour.Tour.Title;

                return(View("Tour/DetailTour", detailTour));
            }
            pagenumber = page ?? 1;
            pagesize   = pageSize ?? 9;
            List <ShowObject>       listTours = CommentController.GetTours(menu.ID);
            IPagedList <ShowObject> listAll   = listTours.ToPagedList(pagenumber, pagesize);
            return(View("Tour/ListTour", listAll));

            #endregion "Kiếu tour"

            //trường hợp: Tour

            #region "Kiếu Activities"

TrangActivities:
            if (idSub.ToString() != "System.Object")
            {
                int idTour;
                int.TryParse(idSub.ToString(), out idTour);
                DetailTour detailTour = CommentController.Detail_Tour(idTour);
                ViewBag.MetaTitle       = detailTour.Tour.MetaTitle ?? detailTour.Tour.Title;
                ViewBag.MetaDesctiption = detailTour.Tour.MetaDescription ?? detailTour.Tour.Title;

                return(View("Tour/DetailTour", detailTour));
            }
            pagenumber = page ?? 1;
            pagesize   = pageSize ?? 9;
            List <ShowObject>       _listActivities = CommentController.TourAll(lan);
            IPagedList <ShowObject> TourAll         = _listActivities.ToPagedList(pagenumber, pagesize);
            return(View("Tour/ListTourByMenuTour", TourAll));


            #endregion "Kiếu Activities"

            #region "Trang Hotel"

TrangHotel:
            if (idSub.ToString() != "System.Object")
            {
                int idHotel;
                int.TryParse(idSub.ToString(), out idHotel);
                ShowDetailHotel showDetailHotel = CommentController.Detail_Hotel(idHotel);

                return(View("Hotel/DetailHotel", showDetailHotel));
            }
            pagenumber = page ?? 1;
            pagesize   = pageSize ?? 9;
            List <ListHotel>       listhotel = CommentController.GetHotels();
            IPagedList <ListHotel> HotelAll  = listhotel.ToPagedList(pagenumber, pagesize);
            return(View("Hotel/ListHotels", HotelAll));


            #endregion "Kiếu Hotel"
            #region "Kiếu Combo"

TrangCombo:
            if (idSub.ToString() != "System.Object")
            {
                int idHotel;
                int.TryParse(idSub.ToString(), out idHotel);
                ShowDetailHotel showDetailHotel = CommentController.Detail_Hotel(idHotel);

                return(View("Hotel/DetailHotel", showDetailHotel));
            }
            pagenumber = page ?? 1;
            pagesize   = pageSize ?? 9;
            List <ListHotel>       listCombo = CommentController.GetHotels();
            IPagedList <ListHotel> Combo     = listCombo.ToPagedList(pagenumber, pagesize);
            return(View("Hotel/ListCombo", Combo));

            #endregion "Kiếu Combo"
        }
Exemplo n.º 8
0
        // code gửi mail xacs nhận booking
        public JsonResult Cormfirmbookingcruise(string name, string email, string phone, string address, string country, string mrs, string content, List <BookingCabin> listservic)
        {
            try
            {
                BookingCruise ds               = (BookingCruise)Session["detaiboookingcruise"];
                var           listcabinemial   = "";
                var           listserviceemial = "";
                double        PriceCabin       = 0;
                double        PriceService     = 0;
                if (ds.CruiseCabin.Count > 0)
                {
                    for (var i = 0; i < ds.CruiseCabin.Count; i++)
                    {
                        var element = ds.CruiseCabin[i];
                        var coutrom = ds.listcabin.FirstOrDefault(a => a.IDCabin == element.ID).CountRom;
                        if (!string.IsNullOrEmpty(element.Price))
                        {
                            var listtab   = JsonConvert.DeserializeObject <List <EPricetabCabin> >(element.Price);
                            var pricerome = listtab.FirstOrDefault(a => a.NameTabCruise == ds.Duration);
                            if (pricerome != null)
                            {
                                if (pricerome.Pricesale < pricerome.Price)
                                {
                                    PriceCabin += coutrom * pricerome.Pricesale;
                                }
                                else
                                {
                                    PriceCabin += coutrom * pricerome.Price;
                                }

                                listcabinemial += "+Room " + (i + 1) + ": " + element.Name + "<br> Number of cabin: " + coutrom + "<br />";
                            }
                        }
                    }
                }
                if (listservic != null)
                {
                    foreach (var i in listservic)
                    {
                        var countservic = db.ServiceCruises.FirstOrDefault(a => a.ID == i.IDCabin);
                        if (countservic != null)
                        {
                            PriceService     += (countservic.Price ?? 0) * i.CountRom;
                            listserviceemial += "+ " + countservic.Name + ":<br>number of guest: " + i.CountRom + "<br>+Price :" + (countservic.Price ?? 0) * i.CountRom + " USD <br />";
                        }
                    }
                }
                var cruisebooking = new BookCruise
                {
                    PriceCabin   = PriceCabin,
                    FullName     = name,
                    Address      = address,
                    Request      = content,
                    Tel          = phone,
                    Gender       = mrs,
                    Email        = email,
                    Adult        = ds.Adult,
                    Country      = country,
                    Child        = Int32.Parse(ds.Child),
                    CreateDate   = DateTime.Now,
                    Departure    = ds.Checkin,
                    NameCruise   = ds.Cruise.Name,
                    Itinerary    = ds.Duration,
                    PriceService = PriceService,
                    Total        = PriceService + PriceCabin
                };
                cruisebooking.InforService = listserviceemial;
                cruisebooking.InforCabin   = listcabinemial;
                db.BookCruises.InsertOnSubmit(cruisebooking);
                db.SubmitChanges();

                //Gửi email xác nhận đặt Tàu

                Hotel     hotel     = CommentController.DetailHotel(Request.Cookies["LanguageID"].Value);
                SendEmail sendEmail =
                    db.SendEmails.FirstOrDefault(
                        a => a.Type == TypeSendEmail.BookRoom && a.LanguageID == Request.Cookies["LanguageID"].Value);

                sendEmail.Title = sendEmail.Title.Replace("{HotelName}", hotel.Name);
                string contentemail = sendEmail.Content;
                contentemail = contentemail.Replace("{NameCruise}", cruisebooking.NameCruise);
                contentemail = contentemail.Replace("{Gender}", cruisebooking.Gender);
                contentemail = contentemail.Replace("{FullName}", cruisebooking.FullName);
                contentemail = contentemail.Replace("{Email}", cruisebooking.Email);
                contentemail = contentemail.Replace("{Tel}", cruisebooking.Tel);
                contentemail = contentemail.Replace("{Address}", cruisebooking.Address);
                contentemail = contentemail.Replace("{City}", "No");
                contentemail = contentemail.Replace("{Country}", cruisebooking.Country);
                contentemail = contentemail.Replace("{Smoking}", "Something");
                contentemail = contentemail.Replace("{InforService}", listserviceemial);
                contentemail = contentemail.Replace("{InforCabin}", listcabinemial);
                contentemail = contentemail.Replace("{Request}", cruisebooking.Request);
                contentemail = contentemail.Replace("{Request}", cruisebooking.Request);
                contentemail = contentemail.Replace("{CheckIn}", cruisebooking.Departure);
                contentemail = contentemail.Replace("{Itinerary}", ds.Duration);
                contentemail = contentemail.Replace("{Adult}", cruisebooking.Adult.ToString());
                contentemail = contentemail.Replace("{Child}", cruisebooking.Child.ToString());
                contentemail = contentemail.Replace("{PriceCabin}", cruisebooking.PriceCabin.ToString());
                contentemail = contentemail.Replace("{PriceService}", cruisebooking.PriceService.ToString());
                contentemail = contentemail.Replace("{Total}", cruisebooking.Total.ToString());
                contentemail = contentemail.Replace("{HotelName}", hotel.Name);
                contentemail = contentemail.Replace("{HotelEmail}", hotel.Email);
                contentemail = contentemail.Replace("{HotelTel}", hotel.Tel);
                contentemail = contentemail.Replace("{Website}", hotel.Website);

                MailHelper.SendMail(cruisebooking.Email, sendEmail.Title, contentemail);
                MailHelper.SendMail(hotel.Email, hotel.Name + " (113)- Booking Cruise of " + cruisebooking.FullName, contentemail);

                return(Json(new { success = true }));
            }
            catch
            {
                return(Json(new { success = false }));
            }
        }
Exemplo n.º 9
0
        public ActionResult BookTour(int id)
        {
            using (var db = new MyDbDataContext())
            {
                var  bookTour = new BookTour();
                Tour tour     = db.Tours.FirstOrDefault(a => a.ID == id);
                if (tour == null)
                {
                    var hotel = CommentController.DetailHotel(Request.Cookies["LanguageID"].Value);
                    ViewBag.Messages = "Error! Can not find the selected tous. For more information, please contact us by email: <a href='mailto:" + hotel.Email + "'>" + hotel.Email + "</a> or phone number: < href='tel:" + hotel.Tel + "'>" + hotel.Tel + "</a>";
                    return(View("Messages"));
                }
                int            caseOption = 0;
                string         name       = "";
                decimal        price      = 0;
                List <TabTour> tabtours   = new List <TabTour>();

                if (tour.HotelService == true)
                {
                    var option = Request.Params["option"];
                    int.TryParse(option, out caseOption);

                    switch (caseOption)
                    {
                    case 1:
                        name  = "3-Star Hotels - " + tour.Title;
                        price = (decimal)tour.ThreeStar;
                        break;

                    case 2:
                        name  = "4-Star Hotels - " + tour.Title;
                        price = (decimal)tour.FourStar;
                        break;

                    case 3:
                        name  = "5-Star Hotels - " + tour.Title;
                        price = (decimal)tour.FiveStar;
                        break;

                    default:
                        var hotel = CommentController.DetailHotel(Request.Cookies["LanguageID"].Value);
                        ViewBag.Messages = "Error! Can not find the selected tous. For more information, please contact us by email: <a href='mailto:" + hotel.Email + "'>" + hotel.Email + "</a> or phone number: < href='tel:" + hotel.Tel + "'>" + hotel.Tel + "</a>";
                        return(View("Messages"));
                    }
                    var tabtour = new TabTour
                    {
                        TourID   = 0,
                        TitleTab = name,
                        Price    = price
                    };
                    tabtours.Add(tabtour);
                }
                else
                {
                    var listTabtours = db.TabTours.Where(a => a.TourID == tour.ID && a.Price > 0).ToList();
                    if (listTabtours.Count > 0)
                    {
                        tabtours.AddRange(listTabtours);
                        if (listTabtours.Count > 1)
                        {
                            price = 0;
                        }
                        else
                        {
                            price = (decimal)listTabtours[0].Price;
                        }
                    }
                    else
                    {
                        var tabtour = new TabTour
                        {
                            TourID   = 0,
                            TitleTab = tour.Title,
                            Price    = tour.PriceSale
                        };
                        tabtours.Add(tabtour);
                    }
                }
                ViewBag.Tour         = tour;
                ViewBag.title        = tour.Title;
                ViewBag.tourID       = tour.ID;
                ViewBag.name         = name;
                ViewBag.price        = price;
                ViewBag.Option       = caseOption;
                bookTour.InfoBooking = tour.Title;
                bookTour.ID          = tour.ID;

                ViewBag.TabTours = tabtours;
                return(View("BookTour", bookTour));
            }
        }
Exemplo n.º 10
0
        public ActionResult SendBooking(MBookTour model)
        {
            string status = "success";

            try
            {
                using (var db = new MyDbDataContext())
                {
                    Tour  tour  = db.Tours.FirstOrDefault(a => a.ID == model.TourId);
                    Hotel hotel = CommentController.DetailHotel(Request.Cookies["LanguageID"].Value);

                    SendEmail sendEmail =
                        db.SendEmails.FirstOrDefault(
                            a => a.Type == TypeSendEmail.BookTour);
                    if (tour == null)
                    {
                        ViewBag.Messages = sendEmail.Error;
                        return(View("Messages"));
                    }

                    //xác định xem tour có phải là option không
                    string  inforBooking = "";
                    decimal price        = 0;
                    if (tour.HotelService == true)
                    {
                        switch (model.Option)
                        {
                        case 1:
                            inforBooking = "3-Star Hotels - " + tour.Title;
                            price        = (decimal)tour.ThreeStar;
                            break;

                        case 2:
                            inforBooking = "4-Star Hotels - " + tour.Title;
                            price        = (decimal)tour.FourStar;
                            break;

                        case 3:
                            inforBooking = "5-Star Hotels - " + tour.Title;
                            price        = (decimal)tour.FiveStar;
                            break;

                        default:
                            ViewBag.Messages = sendEmail.Error;
                            return(View("Messages"));
                        }
                    }
                    else
                    {
                        #region
                        ////xác định lịch trình
                        var tabTour = db.TabTours.FirstOrDefault(a => a.TourID == model.TabTourID);
                        if (tabTour == null)
                        {
                            inforBooking = tour.Title;
                            price        = (decimal)tour.PriceSale;
                        }
                        else
                        {
                            if (db.TabTours.Where(a => a.TourID == model.TourId).Count() > 0)
                            {
                                inforBooking = tour.Title + ", Itinerariy: " + tabTour.TitleTab;
                            }
                            else
                            {
                                inforBooking = tour.Title;
                            }
                            price = (decimal)tabTour.Price;
                        }

                        #endregion
                    }
                    //Check Promotion code

                    double   rate  = 0;
                    DateTime today = DateTime.Now;
                    if (string.IsNullOrEmpty(model.PromotionCode) == false)
                    {
                        PromotionCode Pcode = db.PromotionCodes.FirstOrDefault(c => c.Code == model.PromotionCode && today <= c.EndDay && today >= c.StartDay && c.Status == true);

                        if (Pcode != null)
                        {
                            /*
                             * 1-het ma
                             * 2-ok co ma va con luot dung
                             * 3-loi ko co ma nao
                             */
                            if (Pcode.Used >= Pcode.Total)
                            {
                                rate = 0;
                            }
                            else
                            {
                                rate       = Pcode.Rate / 100;
                                Pcode.Used = Pcode.Used + 1;
                                db.SubmitChanges();
                            }
                        }
                    }


                    //tính giá tour

                    price = price * model.Adult - (price * model.Adult * (decimal)0.6);
                    decimal deposit = 0;
                    decimal Balance = 0;

                    if (model.TypePayment == 1)
                    {
                        deposit = price * ((decimal)tour.Deposit / 100);
                    }
                    Balance = price - deposit;

                    string codeBooking = hotel.CodeBooking + "1";
                    if (db.BookTours.Any())
                    {
                        codeBooking = hotel.CodeBooking + db.BookTours.OrderByDescending(a => a.ID).FirstOrDefault().ID + 1;
                    }

                    BookTour bookTour = new BookTour();
                    bookTour.Departure  = model.Departure;
                    bookTour.Code       = codeBooking;
                    bookTour.CreateDate = DateTime.Now;
                    bookTour.Gender     = model.Gender;
                    bookTour.FullName   = model.FullName;
                    //bookTour.SocialMedia = model.SocialMedia;
                    bookTour.Tel         = model.Tel;
                    bookTour.RoomType    = model.RoomType;
                    bookTour.Country     = model.Country;
                    bookTour.Email       = model.Email;
                    bookTour.Request     = model.Request;
                    bookTour.Adult       = model.Adult;
                    bookTour.InfoBooking = inforBooking;
                    bookTour.Total       = (float)price;
                    //bookTour.Deposit = (float)deposit;
                    bookTour.Balance = (float)Balance;
                    bookTour.TourId  = model.TourId;

                    db.BookTours.InsertOnSubmit(bookTour);
                    db.SubmitChanges();

                    sendEmail.Title = sendEmail.Title.Replace("{HotelName}", hotel.Name);
                    string content = sendEmail.Content;
                    content = content.Replace("{HotelName}", hotel.Name);
                    content = content.Replace("{Deposit}", deposit.ToString());
                    content = content.Replace("{Balance}", Balance.ToString());
                    content = content.Replace("{Code}", bookTour.Code);
                    content = content.Replace("{Departure}", bookTour.Departure.ToString());
                    content = content.Replace("{InfoBooking}", bookTour.InfoBooking);
                    content = content.Replace("{Adult}", bookTour.Adult.ToString());
                    content = content.Replace("{TitleTour}", tour.Title);
                    content = content.Replace("{Price}", price.ToString());
                    content = content.Replace("{Gender}", model.Gender);
                    content = content.Replace("{FullName}", model.FullName);
                    content = content.Replace("{SocialMedia}", model.SocialMedia);
                    content = content.Replace("{Tel}", model.Tel);
                    content = content.Replace("{RoomType}", model.RoomType);
                    content = content.Replace("{Country}", model.Country);
                    content = content.Replace("{Email}", model.Email);
                    content = content.Replace("{Request}", model.Request);

                    if (rate != 0)
                    {
                        content = content.Replace("{Promotion}", model.PromotionCode + "/Rate: " + rate * 100 + " %");
                    }
                    else
                    {
                        content = content.Replace("{Promotion}", "No");
                    }
                    content = content.Replace("{Request}", model.Request);

                    //infor Hotel
                    content = content.Replace("{Add}", hotel.Address);
                    content = content.Replace("{Hotline}", hotel.Hotline);
                    content = content.Replace("{EmailHotel}", hotel.Email);
                    content = content.Replace("{Website}", hotel.Website);

                    MailHelper.SendMail(model.Email, sendEmail.Title, content);
                    MailHelper.SendMail(hotel.Email, hotel.Name + " (" + bookTour.Code + ")- Booking tour of " + model.FullName, content);

                    if (model.TypePayment == 1)
                    {
                        price = price * ((decimal)tour.Deposit / 100);
                        return(RedirectToAction("SubmitInvoidOnePay",
                                                new
                        {
                            idOrder = bookTour.Code,
                            deposit = (Math.Round(price * (decimal)CodeHelper.GetExrate(), 0)) * 100
                        }));
                    }
                    else
                    {
                        return(Redirect("/BookTour/Messages?status=" + status));
                    }
                }
            }
            catch (Exception ex)
            {
                status = "error";
            }

            return(Redirect("/BookTour/Messages?status=" + status));
        }
Exemplo n.º 11
0
        public ActionResult Index(object aliasMenuSub, object idSub, object aliasSub)

        {
            string lan   = Request.Cookies["LanguageID"].Value;
            var    db    = new MyDbDataContext();
            Hotel  hotel = CommentController.DetailHotel(lan);

            ViewBag.MetaTitle       = hotel.MetaTitle;
            ViewBag.MetaDesctiption = hotel.MetaDescription;

            if (aliasMenuSub.ToString() == "System.Object")
            {
                return(View("Index"));
            }
            if (aliasMenuSub.ToString() == "Search")
            {
                string key = Request.Params["key"];
                if (string.IsNullOrEmpty(key))
                {
                    return(View("Tour/Search", new List <Tour>()));
                }
                List <ShowObject> listSearch = new List <ShowObject>();
                listSearch.AddRange(db.Tours.Where(a => a.Status && a.Title.Contains(key)).OrderBy(a => a.Index).Select(a => new ShowObject()
                {
                    ID          = a.ID,
                    Alias       = a.Alias,
                    Description = a.Description,
                    Image       = a.Image,
                    Index       = a.Index,
                    MenuAlias   = a.Alias,
                    Title       = a.Title,
                }).ToList());
                listSearch.AddRange(db.Articles.Where(a => a.Status && a.Title.Contains(key)).OrderBy(a => a.Index).Select(a => new ShowObject()
                {
                    ID          = a.ID,
                    Alias       = a.Alias,
                    Description = a.Description,
                    Image       = a.Image,
                    Index       = a.Index,
                    MenuAlias   = a.Alias,
                    Title       = a.Title,
                }).ToList());

                return(View("Tour/Search", listSearch));
            }
            if (aliasMenuSub.ToString() == "SelectLanguge")
            {
                Language language = db.Languages.FirstOrDefault(a => a.ID == idSub.ToString());
                if (language == null)
                {
                    language = db.Languages.FirstOrDefault();
                }
                HttpCookie langCookie = Request.Cookies["LanguageID"];
                langCookie.Value   = language.ID;
                langCookie.Expires = DateTime.Now.AddDays(10);
                HttpContext.Response.Cookies.Add(langCookie);
                return(Redirect("/"));
            }

            // xác định menu => tìm ra Kiểu hiển thị của menu
            Menu menu = db.Menus.FirstOrDefault(a => a.Alias == aliasMenuSub.ToString());

            if (menu == null)
            {
                return(View("404"));
            }
            //Seo
            ViewBag.MetaTitle       = menu.MetaTitle ?? menu.Title;
            ViewBag.MetaDesctiption = menu.MetaDescription ?? menu.Title;
            ViewBag.Menu            = menu;

            switch (menu.Type)
            {
            //case SystemMenuType.Cruise:
            //    goto TrangCruise;
            case SystemMenuType.Article:
                goto Trangbaiviet;

            case SystemMenuType.Tour:
                goto TrangTour;

            //case SystemMenuType.RoomRate:
            //    goto TrangRoom;
            //case SystemMenuType.Service:
            //    goto Service;
            case SystemMenuType.Ctrip:
                return(RedirectToAction("Index", "CTrip"));

            case SystemMenuType.Contact:
                return(View("Contact"));

            case SystemMenuType.Hotel:
                goto Trangbaiviet;
            //case SystemMenuType.About:
            //    return View("About");

            //case SystemMenuType.Nosvalue:
            //    return View("Nosvalue");

            //case SystemMenuType.Othertours:
            //    return View("OtherTours");

            //case SystemMenuType.HighLightTour:
            //    return View("Tour/ListHighLightTour", CommentController.Tourhots(lan));

            //case SystemMenuType.SpecialTour:
            //    goto SpecialTour;

            //case SystemMenuType.FeedBack:
            //    return View("FeedBack", CommentController.Getfeed());

            //case SystemMenuType.Gallery:
            //    return View("Gallery", CommentController.Gallery());

            //case SystemMenuType.Location:
            //    //Lấy bài viết Location
            //    ViewBag.ArticleByRoomRate = db.Articles.FirstOrDefault(a => a.MenuID == menu.ID);
            //    return View("Location");

            default:
                return(View("Index"));
            }

            #region "Trang bài viết"

Trangbaiviet:
            if (idSub.ToString() != "System.Object")
            {
                int idArticle;
                int.TryParse(idSub.ToString(), out idArticle);
                DetailArticle detailArticle = CommentController.Detail_Article(idArticle);
                ViewBag.MetaTitle       = detailArticle.Article.MetaTitle;
                ViewBag.MetaDesctiption = detailArticle.Article.MetaDescription;
                return(View("Article/DetailArticle", detailArticle));
            }
            //Danh sách bài viết
            List <Article> articles = CommentController.GetArticles(menu.ID);
            if (articles.Count == 1)
            {
                DetailArticle detailArticle = CommentController.Detail_Article(articles[0].ID);
                ViewBag.MetaTitle       = detailArticle.Article.MetaTitle;
                ViewBag.MetaDesctiption = detailArticle.Article.MetaDescription;
                return(View("Article/DetailArticle", detailArticle));
            }
            return(View("Article/ListArticle", articles));

            #endregion "Trang bài viết"

            //Trường hợp: Room

            #region "Kiểu Room & rate"

TrangRoom:
            if (idSub.ToString() != "System.Object")
            {
                int id;
                int.TryParse(idSub.ToString(), out id);
                //Kiểm tra xem alias truyền đến có phải là 1 bài viết không
                var articleRoom = db.Articles.FirstOrDefault(a => a.ID == id);
                if (articleRoom != null)
                {
                    ViewBag.MetaTitle       = articleRoom.MetaTitle;
                    ViewBag.MetaDesctiption = articleRoom.MetaDescription;
                    return(View("Article/DetailArticle", CommentController.Detail_Article(id)));
                }
                //chi tiết Room
                DetailRoom detailRoom = CommentController.Detail_Room(id, menu.ID);
                ViewBag.MetaTitle       = detailRoom.Room.MetaTitle;
                ViewBag.MetaDesctiption = detailRoom.Room.MetaDescription;

                return(View("Room/DetailRoom", detailRoom));
            }
            //Lấy bài viết RoomRate
            var articlrByRoomRate = db.Articles.FirstOrDefault(a => a.MenuID == menu.ID);
            if (articlrByRoomRate != null)
            {
                articlrByRoomRate.MenuAlias = articlrByRoomRate.Alias;
            }
            ViewBag.ArticleByRoomRate = articlrByRoomRate;
            return(View("Room/ListRoom", CommentController.GetRooms(menu.ID)));

            #endregion "Kiểu Room & rate"

            //Trang Service

            #region "Trang Service"

Service:
            if (idSub.ToString() != "System.Object")
            {
                int id;
                int.TryParse(idSub.ToString(), out id);
                DetailService detailService = CommentController.Detail_Service(id);
                ViewBag.MetaTitle       = detailService.Service.MetaTitle;
                ViewBag.MetaDesctiption = detailService.Service.MetaDescription;
                return(View("Service/DetailService", detailService));
            }

            List <Service> services = CommentController.GetServices(menu.ID);
            if (services.Count == 1)
            {
                DetailService detailService = CommentController.Detail_Service(services[0].ID);
                ViewBag.MetaTitle       = detailService.Service.MetaTitle;
                ViewBag.MetaDesctiption = detailService.Service.MetaDescription;
                return(View("Service/DetailService", detailService));
            }
            return(View("Service/ListService", services));

            #endregion "Trang Service"

            //trường hợp: Tour

            #region "Kiếu tour"

TrangTour:
            if (idSub.ToString() != "System.Object")
            {
                int idTour;
                int.TryParse(idSub.ToString(), out idTour);
                DetailTour detailTour = CommentController.Detail_Tour(idTour);
                ViewBag.MetaTitle       = detailTour.Tour.MetaTitle ?? detailTour.Tour.Title;
                ViewBag.MetaDesctiption = detailTour.Tour.MetaDescription ?? detailTour.Tour.Title;
                if ((bool)detailTour.Tour.Deal)
                {
                    return(View("Tour/DetailTourDeal", detailTour));
                }
                return(View("Tour/DetailTour", detailTour));
            }
            if (aliasMenuSub.ToString() == "vietnam-business-visa" || aliasMenuSub.ToString() == "vietnam-tourist-visa")
            {
                var tour = from a in db.Tours
                           join b in db.Menus on a.MenuID equals b.ID
                           where b.Alias == aliasMenuSub.ToString()
                           select a;
                List <Tour> aa = tour.ToList();
                if (tour.Count() == 1)
                {
                    DetailTour detailTour = CommentController.Detail_Tour(aa[0].ID);
                    ViewBag.MetaTitle       = detailTour.Tour.MetaTitle ?? detailTour.Tour.Title;
                    ViewBag.MetaDesctiption = detailTour.Tour.MetaDescription ?? detailTour.Tour.Title;
                    //if ((bool)detailTour.Tour.Deal)
                    //{
                    //    return View("Tour/DetailTourDeal", detailTour);
                    //}
                    return(View("Tour/DetailTour", detailTour));
                }
                else
                {
                    return(View("Tour/ListTour", CommentController.GetTours(menu.ID)));
                }
            }
            return(View("Tour/ListTour", CommentController.GetTours(menu.ID)));

            #endregion "Kiếu tour"

            //trường hợp: Cruise

            #region "Kiếu Cruise"

TrangCruise:
            ViewBag.MenuCruise = db.Menus.FirstOrDefault(a => a.ID == menu.ID).Title;
            return(View("Cruise/ListCruise", CommentController.GetCruise(menu.ID)));

            #endregion "Kiếu Cruise"
        }