public ActionResult Create(TourModel model) { model.Tour.UserId = User.Identity.GetUserId(); if (ModelState.IsValid) { db.Tour.Add(model.Tour); db.SaveChanges(); foreach (var panoId in model.PanoramaListId) { var item = new TourPano() { FkPanoId = panoId, FkTourId = model.Tour.Id }; db.TourPano.Add(item); db.SaveChanges(); } CreateTour(model.PanoramaListId); var rootFolderPath = System.Web.HttpContext.Current.Server.MapPath(@"/Documents/Panoramas/"); Directory.Move(rootFolderPath + "vtour", rootFolderPath + "vtour" + model.Tour.Id); return(RedirectToAction("Index")); } return(View(model)); }
public ActionResult ChangeSliderText(TourModel model, HttpPostedFileBase Photo, int id) { CheckConnection(); if (Photo != null) { string Pname = db.Sliders.Where(x => x.Id == id).FirstOrDefault().Photo; string fullpath = Request.MapPath(Pname); if (System.IO.File.Exists(fullpath)) { System.IO.File.Delete(fullpath); } var NewPhoto = db.Sliders.Where(x => x.Id == id).FirstOrDefault(); string name = MainHelper.Random32(); NewPhoto.Photo = "/images/Slider/" + name + ".jpeg"; using (var newimage = ScaleImage(Image.FromStream(Photo.InputStream, true, true), 2000, 2000)) { string path = Server.MapPath("/images/Slider/" + name + ".jpeg"); newimage.Save(path, ImageFormat.Jpeg); } db.SaveChanges(); } var eng = db.SliderTranslateds.Where(x => x.SliderID == id && x.LangCode == "en-US").FirstOrDefault(); eng.Text = model.TextEng; var rus = db.SliderTranslateds.Where(x => x.SliderID == id && x.LangCode == "ru-RU").FirstOrDefault(); rus.Text = model.TextRus; var geo = db.SliderTranslateds.Where(x => x.SliderID == id && x.LangCode == "ka-GE").FirstOrDefault(); geo.Text = model.TextGeo; db.SaveChanges(); TempData["Success"] = "წარმატებით შეიცვალა"; return(RedirectToAction("MainPage")); }
public FFindTour() { InitializeComponent(); tourModel = new TourModel(); listTour = new DataTable(); tour = new Tour(); rowIndex = 0; }
public FTour() { InitializeComponent(); tourModel = new TourModel(); listTour = new DataTable(); tour = new Tour(); selectedFunction = 0; rowIndex = 0; }
public ActionResult AddTour(TourModel model, HttpPostedFileBase Photo) { CheckConnection(); string name = MainHelper.Random32(); db.Tours.Add(new Tour() { TourDate = model.TourDate, Price = model.Price, Photo = "/images/Tours/" + name + ".jpeg", Active = false, CreateDate = DateTime.Now, }); db.SaveChanges(); using (var newimage = ScaleImage(Image.FromStream(Photo.InputStream, true, true), 1000, 1000)) { string path = Server.MapPath("/images/Tours/" + name + ".jpeg"); newimage.Save(path, ImageFormat.Jpeg); } var Id = db.Tours.Max(x => x.Id); db.TourTranslateds.Add(new TourTranslated() { TourID = Id, LangCode = model.LangEng, CategoryName = model.CategoryNameEng, Title = model.TitleEng, Text = model.TextEng, BigText = model.BigTextEng, }); db.TourTranslateds.Add(new TourTranslated() { TourID = Id, LangCode = model.LangRus, CategoryName = model.CategoryNameRus, Title = model.TitleRus, Text = model.TextRus, BigText = model.BigTextRus, }); db.TourTranslateds.Add(new TourTranslated() { TourID = Id, LangCode = model.LangGeo, CategoryName = model.CategoryNameGeo, Title = model.TitleGeo, Text = model.TextGeo, BigText = model.BigTextGeo, }); db.SaveChanges(); TempData["Success"] = "წარმატებით დაემატა გთხოვთ დაამატოთ ტურის სლაიდერის ფოტოები"; return(RedirectToAction("Tours")); }
public FEditContract() { InitializeComponent(); contractModel = new ContractModel(); listContract = listMember = new DataTable(); contract = new Contract(); updatingContract = new Contract(); memberModel = new MemberModel(); member = new Member(); tourModel = new TourModel(); }
public ActionResult Create() { TourModel model = new TourModel(); var panoramaList = db.Panorama.ToList().Where(item => item.UserId == User.Identity.GetUserId()).ToList(); model.PanoramaListId = panoramaList.Select(item => item.Id).ToList(); ViewBag.ItemInfo = panoramaList.ToList(); return(View(model)); }
public async Task <bool> UpdateAsync(TourModel tour) { var model = await _tour.FirstOrDefaultAsync(x => x.Id == tour.Id); if (model == null) { return(false); } _unitOfWork.Entry(model).CurrentValues.SetValues(tour); return(true); }
public ActionResult EditPost(string tourInfoId, string tourId, TourModel model) { if (ModelState.IsValid) { if (Session["token"] == null) { return(RedirectToAction("Index", "Login")); } string token = Session["token"].ToString(); var client = connector.Initial(); client.Timeout = -1; var request = new RestRequest("admin/tour-infos/" + tourInfoId + "/tours/" + tourId, Method.PUT); request.AddHeader("Authorization", "Bearer " + token); request.AddHeader("Content-Type", "application/json"); request.AddParameter("id", tourInfoId); request.AddParameter("tourId", tourId); request.AddJsonBody(new { Id = tourId, Name = model.Name, Rating = model.Rating, StartDay = model.StartDay, EndDay = model.EndDay, TotalDay = model.TotalDay, TotalNight = model.TotalNight, MaxMember = model.MaxMember, Price = model.Price, Timeline = JsonConvert.DeserializeObject <List <TimelineModel> >(Request["JsonTimelines"]), Service = JsonConvert.DeserializeObject <List <String> >(Request["JsonServices"]), TourInfo = JsonConvert.DeserializeObject <TourInfoModel>(Request["JsonTourInfo"]), CreateBy = JsonConvert.DeserializeObject <UserModel>(Request["JsonCreateBy"]), JoinAt = Request["JsonJoinAt"], AcceptedAt = Request["JsonAcceptedAt"] }); IRestResponse response = client.Execute(request); if (response.IsSuccessful) { APIResultModel result = JsonConvert.DeserializeObject <APIResultModel>(response.Content); if (result.ErrorCode != 0) { ViewBag.error = result.Message; return(RedirectToAction("Edit", "Tour", new { tourInfoId = tourInfoId, tourId = tourId })); } return(RedirectToAction("Detail", "TourInfo", new { id = tourInfoId })); } else { return(RedirectToAction("Edit", "Tour", new { tourInfoId = tourInfoId, tourId = tourId })); } } return(View(model)); }
public async Task <bool> SaveAsync(TourModel tour) { if (tour.Id > 0) { return(await UpdateAsync(tour)); } else { return(await AddAsync(tour)); } }
public ActionResult Edit(TourModel Model) { string error = ""; try { if (ModelState.IsValid) { int ClientId = GetClientId(Model.ClientName); int ExcursionId = GetExcursionId(Model.ExcursionName); OrderedTourManager.EditTourInfo(Model.OrderedTourId, Model.Date, ClientId, ExcursionId); List <OrderedTour_ExcursionSight> excursionSight = excMan.GetExcursionSightInfo(Model.OrderedTourId); var Count = excursionSight.Count > Model.ExcursionSight.Count ? excursionSight.Count : Model.ExcursionSight.Count; int?excursionSightId; for (int i = 0; i < Count; i++) { try { excursionSightId = (int)GetExcursionSightId(Model.ExcursionSight[i], ExcursionId); } catch { excursionSightId = null; } OrderedTour_ExcursionSight ExcursionSightToOrderedTour = OrderedTourManager.GetExcursionSightId(i, Model.OrderedTourId); if (ExcursionSightToOrderedTour != null) { OrderedTourManager.EditExcursionIdinOrderedTour(ExcursionSightToOrderedTour, excursionSightId); } else { AddExcursionSight(Model.OrderedTourId, excursionSightId, i); } } } else { error = "Form is incorrect."; return(Json(new { status = false, error }, JsonRequestBehavior.AllowGet)); } return(Json(new { status = true, error }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { error = "Error occured:" + ex.Message; return(Json(new { status = false, error }, JsonRequestBehavior.AllowGet)); } }
public ActionResult Edit([Bind(Include = "Id,Name,Description,PriceUSD,PriceEGP,Duration,AvalibleFrom,AvalibleTo,PlaceId,PhotoId")] TourModel tourModel) { if (ModelState.IsValid) { var tour = Mapper.Map <Tour>(tourModel); unitOfWork.TourRepository.Update(tour); unitOfWork.Save(); return(RedirectToAction("Index")); } var places = unitOfWork.PlaceRepository.Get(); ViewBag.PlaceId = new SelectList(places, "Id", "Name"); return(View(tourModel)); }
public ActionResult Create([Bind(Include = "Id,Name,Description,PriceUSD,PriceEGP,Duration,AvalibleFrom,AvalibleTo,PlaceId,PhotoId")] TourModel tourModel, List <HttpPostedFileBase> files) { if (ModelState.IsValid) { var tour = Mapper.Map <Tour>(tourModel); unitOfWork.TourRepository.Insert(tour); unitOfWork.Save(); var first = true; foreach (var file in files) { if (file != null && file.ContentLength > 0) { var extension = Path.GetExtension(file.FileName); var fileExtension = extension.ToLower(); if (allowedExtensions.Contains(fileExtension)) { var uniqe = Guid.NewGuid(); string path = Path.Combine(Server.MapPath("~/Uploads"), uniqe + extension); file.SaveAs(path); var photoModel = new PhotoModel(); photoModel.Name = uniqe + extension; photoModel.Type = PhotoType.Tour; photoModel.ItemId = tour.Id; var photo = Mapper.Map <Photo>(photoModel); unitOfWork.PhotoRepository.Insert(photo); if (first) { tour.Photo = photo; unitOfWork.TourRepository.Update(tour); first = false; } } else { ModelState.AddModelError("Photo", "please select photos in these formats .jpg, .jpeg, .png"); var placess = unitOfWork.PlaceRepository.Get(); ViewBag.PlaceId = new SelectList(placess, "Id", "Name"); return(View(tourModel)); } } } unitOfWork.Save(); return(RedirectToAction("Index")); } var places = unitOfWork.PlaceRepository.Get(); ViewBag.PlaceId = new SelectList(places, "Id", "Name"); return(View(tourModel)); }
public async Task <IActionResult> PostTour([FromBody] TourModel tour) { Console.WriteLine("PostTour"); Console.WriteLine(tour.Title); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } await _tourService.AddAsync(tour); await _unitOfWork.SaveAllChangesAsync(); return(CreatedAtAction("GetTour", new { id = tour.Id }, tour)); }
}// GET: Tour/Details/5 public ActionResult Details(int id = 0) { var TourModel = new TourModel(); var general = url + "Tours/GetTourById?TourId=" + id; var responseMessage = _client.GetAsync(general).Result; if (!responseMessage.IsSuccessStatusCode) { return(View(TourModel)); } var responseData = responseMessage.Content.ReadAsStringAsync().Result; TourModel = JsonConvert.DeserializeObject <TourModel>(responseData); return(View(TourModel)); }
public static TourModel ToEntity(this TourPostDto dto, PlayerModel creator, CourseModel course) { var tour = new TourModel { Name = dto.Name, Description = dto.Description, Creator = creator, Games = dto.Games.Select(g => g.ToEntity(creator, course, new CardModel { IsGatheringCard = true })).ToList() }; return(tour); }
private static TourModel ConvetDbTourToTourModel(Tour dbTour) { var tour = new TourModel { TourID = dbTour.TourID, TourName = dbTour.TourName, TourDescription = dbTour.TourDescription, CategoryID = dbTour.CategoryID, CategoryName = dbTour.CategoryID.HasValue ? TourDBprovider.GetCategoryNameById(dbTour.CategoryID.Value) : string.Empty, Price = dbTour.ClassID.HasValue ? TourDBprovider.GetTourPriceByTourClassId(dbTour.ClassID.Value) : 0 }; var discount = TourDBprovider.GetDiscountByTourId(tour.TourID); tour.FinalPrice = tour.Price * discount; return(tour); }
/// <summary> /// Populates the PayloadDetails object's properties from the given Content object's properties. /// </summary> /// <param name="thisObject">PayloadDetails object</param> /// <param name="contentDetail">Content Details object</param> /// <returns>PayloadDetails instance</returns> public static PayloadDetails SetValuesFrom(this PayloadDetails thisObject, ContentDetails contentDetail) { if (contentDetail != null) { if (thisObject == null) { thisObject = InitializePayload(); } if (contentDetail.ContentData is FileDetail) { var fileDetail = contentDetail.ContentData as FileDetail; if (contentDetail.ContentData.ContentType == ContentTypes.Tours) { var tour = new TourModel(); tour.SetValuesFrom(contentDetail); thisObject.Tours.Add(tour); } else if (contentDetail.ContentData.ContentType == ContentTypes.Wtml) { var childCollection = new PayloadDetails(); childCollection.Name = contentDetail.Name; childCollection.Id = fileDetail.AzureID.ToString(); childCollection.MSRComponentId = contentDetail.ID; childCollection.Group = "Explorer"; childCollection.IsCollection = true; childCollection.Thumbnail = (contentDetail.Thumbnail != null && contentDetail.Thumbnail.AzureID != Guid.Empty) ? contentDetail.Thumbnail.AzureID.ToString() : null; childCollection.Permission = contentDetail.UserPermission; thisObject.Children.Add(childCollection); } else { var place = new Place(); place.SetValuesFrom(contentDetail); thisObject.Links.Add(place); } } else { var place = new Place(); place.SetValuesFrom(contentDetail); thisObject.Links.Add(place); } } return(thisObject); }
public ActionResult CreatePost(TourModel model) { if (ModelState.IsValid) { if (Session["token"] == null) { return(RedirectToAction("Index", "Login")); } string token = Session["token"].ToString(); var client = connector.Initial(); client.Timeout = -1; var request = new RestRequest("admin/tour-infos/" + model.TourInfoId + "/tours", Method.POST); request.AddHeader("Authorization", "Bearer " + token); request.AddHeader("Content-Type", "application/json"); request.AddParameter("id", model.TourInfoId); request.AddJsonBody(new { Name = model.Name, StartDay = model.StartDay, EndDay = model.EndDay, TotalDay = model.TotalDay, TotalNight = model.TotalNight, MaxMember = model.MaxMember, TourInfoId = model.TourInfoId, Price = model.Price, }); IRestResponse response = client.Execute(request); if (response.IsSuccessful) { APIResultModel result = JsonConvert.DeserializeObject <APIResultModel>(response.Content); if (result.ErrorCode != 0) { ViewBag.error = result.Message; return(View()); } return(RedirectToAction("Index", "Place")); } else { return(RedirectToAction("Create", "Place")); } } return(View(model)); }
public TourViewModel() { CreateTourCommand = new DelegateCommand <string[]>(str => { if ((str[0] != "") && (str[1] != "") && (str[2] != "") && (str[3] != "") && (str[4] != "") && (str[5] != "")) { TourModel.CreatePersonalTicket(str[0], str[1], str[2], str[3], str[4], Convert.ToInt32(str[5])); EnterModel.Close_Tour_Window(); } else { MessageBox.Show("Вы заполнили не все поля!"); } }); AvailableCounties = ConnectionToDB.getCountriesForComboBox(); }
public ActionResult Hotel(int page = 1, int pageSize = 6) { //Display Active Hotel ViewBag.isActive = UtilContants.HOTELS_NAV; var hotel = new HotelModel(); var listHotel = hotel.listHotel().ToPagedList(page, pageSize); //declare TourModel to get listComboBoxToPlace method TourModel home = new TourModel(); var listComboBoxToPlace = home.listComboBoxToPlace(); // call ListContainerHotel TO contain all list ListContainerHotel listContainer = new ListContainerHotel(); listContainer.Hotel = listHotel; listContainer.listComboBoxToPlace = listComboBoxToPlace; return(View(listContainer)); }
public async Task <ActionResult> CreateTour([FromBody] TourModel tourModel) { TourDTO tourDTO = new TourDTO { Name = tourModel.Name, City = tourModel.City, Location = tourModel.Location, Price = tourModel.Price, PlacesCount = tourModel.PlacesCount, Description = tourModel.Description, Date = tourModel.Date }; var operationDetails = await _tourService.AddTour(tourDTO); Log.Information($"Tour{tourDTO.Id} is added succesfully"); return(Ok(operationDetails)); }
public ActionResult ChangeAddedServices(TourModel model, int Id, HttpPostedFileBase Photo) { CheckConnection(); var Eng = db.ServicesTranslateds.Where(x => x.TourID == Id && x.LangCode == "en-US").FirstOrDefault(); var Rus = db.ServicesTranslateds.Where(x => x.TourID == Id && x.LangCode == "ru-RU").FirstOrDefault(); var Geo = db.ServicesTranslateds.Where(x => x.TourID == Id && x.LangCode == "ka-GE").FirstOrDefault(); Eng.Service.TourDate = model.TourDate; Eng.Service.Price = model.Price; if (Photo != null) { string name = MainHelper.Random32(); string Pname = Eng.Service.Photo; string fullpath = Request.MapPath(Pname); if (System.IO.File.Exists(fullpath)) { System.IO.File.Delete(fullpath); } Eng.Service.Photo = "/images/Services/" + name + ".jpeg"; using (var newimage = ScaleImage(Image.FromStream(Photo.InputStream, true, true), 1000, 1000)) { string path = Server.MapPath("/images/Services/" + name + ".jpeg"); newimage.Save(path, ImageFormat.Jpeg); } } Eng.CategoryName = model.CategoryNameEng; Eng.Title = model.TitleEng; Eng.Text = model.TextEng; Eng.BigText = model.BigTextEng; db.SaveChanges(); Rus.CategoryName = model.CategoryNameRus; Rus.Title = model.TitleRus; Rus.Text = model.TextRus; Rus.BigText = model.BigTextRus; db.SaveChanges(); Geo.CategoryName = model.CategoryNameGeo; Geo.Title = model.TitleGeo; Geo.Text = model.TextGeo; Geo.BigText = model.BigTextGeo; db.SaveChanges(); TempData["Success"] = "წარმატებით შეიცვალა"; return(RedirectToAction("ChnageService")); }
public async Task <ActionResult> ChangeTour([FromBody] TourModel tourModel) { TourDTO tourDTO = new TourDTO { Name = tourModel.Name, Location = tourModel.Location, City = tourModel.City, Description = tourModel.Description, Date = tourModel.Date, ImageUrl = tourModel.ImageUrl, PlacesCount = tourModel.PlacesCount, UserId = tourModel.UserId, Id = tourModel.Id, Price = tourModel.Price }; var operationDetails = await _tourService.ChangeTourInformation(tourDTO); return(Ok(operationDetails)); }
public async Task <IActionResult> PutTour([FromRoute] int id, [FromBody] TourModel tour) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != tour.Id) { return(BadRequest()); } if (await _tourService.UpdateAsync(tour)) { _unitOfWork.SaveAllChanges(); return(Ok(tour)); } return(NotFound()); }
/// <summary> /// Populates the PayloadDetails object's properties from the given collection of ContentsView object's properties. /// </summary> /// <param name="thisObject">PayloadDetails object</param> /// <param name="contents">ContentsView objects</param> /// <returns>PayloadDetails instance</returns> public static PayloadDetails SetValuesFrom(this PayloadDetails thisObject, IEnumerable <ContentsView> contents) { if (contents != null) { if (thisObject == null) { thisObject = InitializePayload(); } foreach (var content in contents) { if (content.Filename.EndsWith(Constants.TourFileExtension, StringComparison.OrdinalIgnoreCase)) { var tour = new TourModel(); tour.SetValuesFrom(content); thisObject.Tours.Add(tour); } else if (content.Filename.EndsWith(Constants.CollectionFileExtension, StringComparison.OrdinalIgnoreCase)) { var childCollection = new PayloadDetails(); childCollection.Name = content.Title; childCollection.Id = content.ContentAzureID.ToString(); childCollection.MSRComponentId = content.ContentID; childCollection.Group = "Explorer"; childCollection.IsCollection = true; childCollection.Thumbnail = (content.ThumbnailID.HasValue && content.ThumbnailID != Guid.Empty) ? content.ThumbnailID.ToString() : null; // Permissions for Content view are hard-coded to Read as it is used for browse childCollection.Permission = Permission.Reader; thisObject.Children.Add(childCollection); } else { var place = new Place(); place.SetValuesFrom(content); thisObject.Links.Add(place); } } } return(thisObject); }
public ActionResult Index() { //Display Active Home ViewBag.isActive = UtilContants.HOME_NAV; TourModel model = new TourModel(); var tour = model.listTourHot(); var hotel = model.listHotel(); var listComboBoxToPlace = model.listComboBoxToPlace(); var listComboBoxFromPlace = model.listComboBoxFromPlace(); TourHotel listContainer = new TourHotel(); listContainer.Tour = tour; listContainer.Hotel = hotel; listContainer.listComboBoxFromPlace = listComboBoxFromPlace; listContainer.listComboBoxToPlace = listComboBoxToPlace; return(View(listContainer)); }
public ActionResult AddSlider(HttpPostedFileBase Photo, TourModel model) { CheckConnection(); if (Photo != null) { string name = MainHelper.Random32(); db.Sliders.Add(new Slider() { Photo = "/images/Slider/" + name + ".jpeg" }); using (var newimage = ScaleImage(Image.FromStream(Photo.InputStream, true, true), 2000, 2000)) { string path = Server.MapPath("/images/Slider/" + name + ".jpeg"); newimage.Save(path, ImageFormat.Jpeg); } db.SaveChanges(); int id = db.Sliders.Max(x => x.Id); db.SliderTranslateds.Add(new SliderTranslated() { SliderID = id, LangCode = model.LangEng, Text = model.TextEng, }); db.SliderTranslateds.Add(new SliderTranslated() { SliderID = id, LangCode = model.LangRus, Text = model.TextRus, }); db.SliderTranslateds.Add(new SliderTranslated() { SliderID = id, LangCode = model.LangGeo, Text = model.TextGeo, }); db.SaveChanges(); } TempData["Success"] = "წარმატებით დაემატა"; return(RedirectToAction("MainPage")); }
public IActionResult Index(string tourUrlName) { if (tourUrlName == null) { return(Redirect("/Tours")); } ViewBag.CurrentPage = "Tours"; var tourPages = _pageService.GetAll(PageType.Tour); var tourPage = tourPages.Find(p => p.UrlName == tourUrlName); var model = new TourModel { TourPage = tourPage, TourPages = tourPages, Tags = _tagService.GetAll(tourPage.Id) }; return(View(model)); }
public ActionResult Tour(int page = 1, int pageSize = 6) { //Display Active Tour ViewBag.isActive = UtilContants.PLACE_NAV; ToursModel model = new ToursModel(); TourModel home = new TourModel(); var tours = model.listAllTours().ToPagedList(page, pageSize); var listComboBoxToPlace = home.listComboBoxToPlace(); var listComboBoxFromPlace = home.listComboBoxFromPlace(); ListContainerTravel listContainer = new ListContainerTravel(); listContainer.Tour = tours; listContainer.listComboBoxFromPlace = listComboBoxFromPlace; listContainer.listComboBoxToPlace = listComboBoxToPlace; return(View(listContainer)); }