public ViewResult CreateHotel() { var context = new TourEntities1(); EditHotelModel model = new EditHotelModel() { Hotel = new Hotel(), Resort = new SelectList(context.Resort, "Id", "Name") }; return View("EditHotel", model); }
public ViewResult Create() { var context = new TourEntities1(); EditHotTourModel model = new EditHotTourModel() { HotTour = new HotTours(), Hotel = new SelectList(context.Hotel, "Id", "Name") }; return View("Edit", model); }
public ActionResult Create(Photo photo, IEnumerable<HttpPostedFileBase> files) { var context = new TourEntities1(); if (!ModelState.IsValid) return View(photo); if (files.Count() == 0 || files.FirstOrDefault() == null) { ViewBag.error = "Please choose a file"; return View(photo); } foreach (var file in files) { if (file.ContentLength == 0) continue; var model = new Photo(); model.Decription = photo.Decription; var fileName = Guid.NewGuid().ToString(); var extension = System.IO.Path.GetExtension(file.FileName).ToLower(); MemoryStream ms = new MemoryStream(); file.InputStream.CopyTo(ms); file.InputStream.Dispose(); ms.Seek(0, SeekOrigin.Begin); //var img = System.Drawing.Image.FromStream(ms); //img.Save("./asd123.png"); using (var img1 = System.Drawing.Image.FromStream(ms)) { //model.ThumbPath = String.Format("~{2}ImageGallery{2}thumbs{2}{0}{1}", fileName, extension, Path.DirectorySeparatorChar); //model.ImagePath = String.Format("~{2}ImageGallery{2}{0}{1}", fileName, extension, Path.DirectorySeparatorChar); model.ThumbPath = String.Format("/ImageGallery/thumbs/{0}{1}", fileName, extension); model.ImagePath = String.Format("/ImageGallery/{0}{1}", fileName, extension); // Save thumbnail size image, 100 x 100 SaveToFolder(img1, fileName, extension, new Size(100, 100), model.ThumbPath); // Save large size image, 800 x 800 SaveToFolder(img1, fileName, extension, new Size(600, 600), model.ImagePath); } // Save record to database model.CreatedOn = DateTime.Now; context.Photo.Add(model); context.SaveChanges(); } return RedirectToAction("Index", "Photo"); }
// // GET: /Photo/ public ActionResult Index(string filter = null, int page = 1, int pageSize = 20) { var records = new PagedList<Photo>(); var context = new TourEntities1(); ViewBag.filter = filter; records.Content = context.Photo .Where(x => filter == null || (x.Decription.Contains(filter))) .OrderByDescending(x => x.Id) .Skip((page - 1) * pageSize) .Take(pageSize) .ToList(); // Count records.TotalRecords = context.Photo .Where(x => filter == null || (x.Decription.Contains(filter))).Count(); records.CurrentPage = page; records.PageSize = pageSize; return View(records); }
private void FillModelOrder(ref FormsAuthProvider model) { model = model ?? new FormsAuthProvider(); var context = new TourEntities1(); //model.Country = new SelectList(context.Country, "Name", "Name"); }
public ActionResult Placements() { var context = new TourEntities1(); var data = context.Placement.ToList(); return View(data); }
public void SavePlacement(Placement b) { var context = new TourEntities1(); if (b.Id == 0) { context.Placement.Add(b); } else { Placement dbEntry = context.Placement.Find(b.Id); if (dbEntry != null) { dbEntry.Description = b.Description; dbEntry.Name = b.Name; } } context.SaveChanges(); }
public ActionResult ResortList() { TourEntities1 db = new TourEntities1(); var data = db.Resort.ToList(); return View(data); }
//public ActionResult AllAbout() //{ // var data = context.About.ToList(); // return View(data); //} //public ViewResult AboutEdit(int Id = 10) //{ // var context = new TourEntities1(); // var dat = context.About.FirstOrDefault(p => p.Id == Id); // return View(dat); //} //[HttpPost] //[ValidateInput(false)] //public ActionResult AboutEdit(About tour, HttpPostedFileBase image) //{ // var context = new TourEntities1(); // if (ModelState.IsValid) // { // SaveAbout(tour); // TempData["message"] = string.Format("{0} has been saved", tour.Name); // return RedirectToAction("Index", "Admin"); // } // else // { // return View(tour); // } //} //public ActionResult ONas() //{ // var context = new TourEntities1(); // var data = context.About.ToList(); // return View(data); //} //public void SaveAbout(About b) //{ // var context = new TourEntities1(); // if (b.Id == 0) // { // context.About.Add(b); // } // else // { // About dbEntry = context.About.Find(b.Id); // if (dbEntry != null) // { // dbEntry.Description = b.Description; // dbEntry.Name = b.Name; // } // } // context.SaveChanges(); //} public ActionResult Index(int? Id) { var context = new TourEntities1(); var data = context.HotTours.Include(m => m.Hotel).ToList(); return View(data); }
public void SaveNews(News b) { var context = new TourEntities1(); if (b.Id == 0) { b.Date = DateTime.Now; context.News.Add(b); } else { News dbEntry = context.News.Find(b.Id); if (dbEntry != null) { dbEntry.Name = b.Name; dbEntry.Description = b.Description; dbEntry.Date = DateTime.Now; } } context.SaveChanges(); }
public ViewResult ResortDetails(int Id) { var context = new TourEntities1(); var data = context.Resort.Find(Id); return View(data); }
public FileContentResult GetImage(int Id) { var context = new TourEntities1(); HotTours tours = context.HotTours.FirstOrDefault(p => p.Id == Id); if (tours != null) { return File(tours.ImageData, tours.ImageMimeType); } else { return null; } }
public FileContentResult GetImageHotel(int Id) { var context = new TourEntities1(); Hotel hotel = context.Hotel.FirstOrDefault(p => p.Id == Id); if (hotel != null) { return File(hotel.ImageData, hotel.ImageMimeType); } else { return null; } }
public ActionResult CountDetails(int Id) { var context = new TourEntities1(); var data = context.Country.Find(Id); return View("PartialCountries", data); }
public ActionResult Countries() { var context = new TourEntities1(); var data = context.Country.Include(p => p.Resort).ToList(); return View(data); }
private void FillModelEditResort(ref EditResortModel model, int Id) { model = model ?? new EditResortModel(); var context = new TourEntities1(); model.Resort = context.Resort.FirstOrDefault(p => p.Id == Id); model.Country = new SelectList(context.Country, "Id", "Name"); }
private void FillModelEditHotTour(ref EditHotTourModel model, int Id) { model = model ?? new EditHotTourModel(); var context = new TourEntities1(); model.HotTour = context.HotTours.FirstOrDefault(p => p.Id == Id); model.Hotel = new SelectList(context.Hotel, "Id", "Name"); }
public void SaveResort(Resort b) { var context = new TourEntities1(); if (b.Id == 0) { context.Resort.Add(b); } else { Resort dbEntry = context.Resort.Find(b.Id); if (dbEntry != null) { dbEntry.Name = b.Name; dbEntry.Description = b.Description; dbEntry.CountryId = b.CountryId; dbEntry.ImageData = b.ImageData ?? dbEntry.ImageData; dbEntry.ImageMimeType = b.ImageMimeType; } } context.SaveChanges(); }
public void SaveHotel(Hotel b) { var context = new TourEntities1(); if (b.Id == 0) { context.Hotel.Add(b); } else { Hotel dbEntry = context.Hotel.Find(b.Id); if (dbEntry != null) { dbEntry.Name = b.Name; dbEntry.Description = b.Description; dbEntry.ImageData = b.ImageData ?? dbEntry.ImageData; dbEntry.ImageMimeType = b.ImageMimeType; dbEntry.Category = b.Category; dbEntry.CountryId = b.CountryId; dbEntry.ResortId = b.ResortId; } } context.SaveChanges(); }
public ActionResult Hotels(int? Id) { TourEntities1 db = new TourEntities1(); var data = db.Hotel.ToList(); return View(data); }
public ActionResult Details(int Id) { var context = new TourEntities1(); var data = context.HotTours.Find(Id); return View("PartialDetails", data); }
public void SaveHotTour(HotTours b) { var context = new TourEntities1(); if (b.Id == 0) { context.HotTours.Add(b); } else { HotTours dbEntry = context.HotTours.Find(b.Id); if (dbEntry != null) { dbEntry.Description = b.Description; dbEntry.Price = b.Price; dbEntry.Category = b.Category; dbEntry.ImageData = b.ImageData ?? dbEntry.ImageData; dbEntry.ImageMimeType = b.ImageMimeType; dbEntry.AmountPeople = b.AmountPeople; dbEntry.DepartureDay = b.DepartureDay; dbEntry.Food = b.Food; dbEntry.Period = b.Period; dbEntry.TourType = b.TourType; dbEntry.Location = b.Location; dbEntry.HotelId = b.HotelId; } } context.SaveChanges(); }
public FileContentResult GetImageCountry(int Id) { var context = new TourEntities1(); Country count = context.Country.FirstOrDefault(p => p.Id == Id); if (count != null) { return File(count.ImageData, count.ImageMimeType); } else { return null; } }
public ViewResult EditPlacement(int Id = 1) { var context = new TourEntities1(); var dat = context.Placement.FirstOrDefault(p => p.Id == Id); return View(dat); }
public FileContentResult GetImageResort(int Id) { var context = new TourEntities1(); Resort resort = context.Resort.FirstOrDefault(p => p.Id == Id); if (resort != null) { return File(resort.ImageData, resort.ImageMimeType); } else { return null; } }
public ActionResult EditPlacement(Placement tour, HttpPostedFileBase image) { var context = new TourEntities1(); if (ModelState.IsValid) { SavePlacement(tour); TempData["message"] = string.Format("{0} has been saved", tour.Name); return RedirectToAction("Index", "Admin"); } else { // there is something wrong with the data values return View(tour); } }
public ActionResult OrderHotel(OrderHotelModel model) { var context = new TourEntities1(); int id = Int32.Parse(Request.Params["id"]); model.Hotels = context.Hotel.Single(s => s.Id == id); //if (Session["Captcha"] == null || Session["Captcha"].ToString() != model.Captcha) //{ // ModelState.AddModelError("Captcha", "Неправильный ответ, поробуйте еще раз"); // //dispay error and generate a new captcha // return View(model); //} if (ModelState.IsValid) { DateTime thisday = DateTime.Now; int order_number = 0; using (var iter = GetNonRepeatingDigits().GetEnumerator()) while (iter.MoveNext() && order_number < 10000) order_number = order_number * 10 + iter.Current; MailAddress from = new MailAddress("*****@*****.**"); MailAddress to = new MailAddress(model.MailAdress); MailAddress To = new MailAddress("*****@*****.**"); //[email protected]" MailMessage message1 = new MailMessage(from, to); MailMessage message2 = new MailMessage(from, To); message1.Subject = "Информация о заказе!"; message1.Body = "Вы заказали отель:" + model.Hotels.Name + "\r\n" + "Описание" + model.Hotels.Description + "\r\n" + "В ближайшее время наши менеджеры обработают Вашу заявку и свяжутся с Вами по указанным в заказе контактам. " + "\r\n" + "\r\n" + "\r\n" + "С уважением и благодарностью сотрудники ТА Лучший подарок" + "\r\n" + "г. Харьков, Полтавский шлях 123, 2 этаж, офис №6" + "\r\n" + "тел. (057) 297-60-97" + "\r\n" + "моб. 066-626-00-76" + "\r\n" + "068-922-70-76"; message1.IsBodyHtml = true; message2.Subject = "Заказ отеля!!"; message2.Body = "Заказ отеля!" + "\r\n" + "Имя туриста: " + model.Name + "\r\n" + model.MailAdress + "\r\n" + "Телефон: " + model.Phone + "\r\n" + "Пожелания:" + model.Comment + "\r\n" + "Id тура:" + model.Hotels.Id + "\r\n" + "Курорт: " + model.Hotels.Resort.Name + "\r\n" + "Отель: " + model.Hotels.Name + "\r\n" + model.Hotels.Description; SmtpClient smtp = new SmtpClient(); smtp.Host = "smtp-5.1gb.ua"; smtp.EnableSsl = false; System.Net.NetworkCredential NetworkCred = new System.Net.NetworkCredential(); NetworkCred.UserName = "******"; NetworkCred.Password = "******"; smtp.UseDefaultCredentials = true; smtp.Credentials = NetworkCred; try { Task.Factory.StartNew((Action)(() => { smtp.Send(message1); smtp.Send(message2); }), TaskCreationOptions.AttachedToParent | TaskCreationOptions.LongRunning); } catch (Exception ex) { } return RedirectToAction("AddToCart"); } else { return View(model); } }
public ActionResult GetItems(int id) { var context = new TourEntities1(); var data = context.Hotel.ToList(); var list = context.Resort.Where(c => c.CountryId == id).OrderBy(s => s.Name).ToList(); list.Insert(0, new Resort { Id = -1, Name = "Выберите Курорт" }); var test = list.ToDDLContent(s => s.Id, s => s.Name); return Content(test); }
public ViewResult CountryDetails(int Id) { var context = new TourEntities1(); var data = context.Country.Find(Id); context.Entry(data).Collection(d => d.Resort).Load(); return View(data); }
public ActionResult Hotel(int? hotelId, int? resortId, int? countrId) { var context = new TourEntities1(); var data = context.Hotel.ToList(); if (resortId == -1 && countrId != -1) { data = context.Hotel.Where(s => s.Resort.CountryId == countrId).ToList(); } else { data = context.Hotel.Where(s => (resortId.HasValue && s.ResortId == resortId.Value) || (countrId.HasValue && s.CountryId == countrId.Value)).ToList(); } return PartialView("PartialHotels", data); }