Пример #1
0
        public PlaceViewModel PlaceToViewModel(Place place)
        {
            if (place == null)
            {
                return(null);
            }
            var placeViewModel = new PlaceViewModel();

            placeViewModel.ID   = place.ID;
            placeViewModel.Name = place.Name;

            var hotelViewModels = new List <HotelViewModel>();

            if (place.Hotels == null || place.Hotels.Count < 1)
            {
                return(placeViewModel);
            }
            place.Hotels.ToList().ForEach(hotel =>
            {
                var hotelViewModel = HotelToViewModel(hotel);
                hotelViewModels.Add(hotelViewModel);
            });
            placeViewModel.Hotels = hotelViewModels;

            return(placeViewModel);
        }
Пример #2
0
        public ActionResult TicketInfo(PlaceViewModel pl, int id)
        {
            try {
                var ticket = new TicketDTO
                {
                    TrainNumber    = pl.Train,
                    PassengerPlace = pl.Place,
                    Wagon          = pl.Wagon,
                };

                var res = ts.EditTickets(ticket, id);
                if (res == null)
                {
                    unit.Save();
                    unit.Dispose();
                }
                else
                {
                    ModelState.AddModelError(string.Empty, res);
                    return(View());
                }

                return(RedirectToAction("UserList"));
            }
            catch (Exception ex)
            {
                return(View(ex.Message));
            }
        }
Пример #3
0
        public ActionResult PlaceInfo(string placeId)
        {
            string placeInfo = GetPlaceJson("https://maps.googleapis.com/maps/api/place/details/json?placeid=" + placeId + "&key=AIzaSyDAVUjsKnnRMjs32MZxlWvpAu-tQeQKMpY&language=ru");

            dynamic foo = JObject.Parse(placeInfo);

            try
            {
                PlaceViewModel targetPlace = new PlaceViewModel()
                {
                    Id           = placeId,
                    Name         = foo.result.name,
                    Address      = foo.result.formatted_address,
                    PhoneNumber  = foo.result.international_phone_number,
                    IconPath     = foo.result.icon,
                    GoogleRating = foo.result.rating,
                    PhotosUrls   = new object[foo.result.photos.Count],
                    //Reviews = (placeInfoDb.Reviews.Where(r => r.GooglePlaceId == placeId).Count() > 0) ? placeInfoDb.Reviews.Where(r => r.GooglePlaceId == placeId).ToList() : new List<Review>()
                };
                for (int i = 0; i < foo.result.photos.Count; i++)
                {
                    targetPlace.PhotosUrls[i] = (foo.result.photos != null) ? "https://maps.googleapis.com/maps/api/place/photo?maxwidth=300&photoreference=" + foo.result.photos[i].photo_reference + "&key=AIzaSyDAVUjsKnnRMjs32MZxlWvpAu-tQeQKMpY" : foo.result.icon;
                }

                return(View(targetPlace));
            }
            catch (Exception ex)
            {
                return(View("Index"));
            }
        }
Пример #4
0
        // api/Place/GetNearBy
        public IHttpActionResult GetNearBy(float objlng, float objlat, float distance, int scope)//scope: 0_Nation, 1_City, 2_Street, Kinds
        {
            var places = _PlaceService.GetPlacesNearBy(objlng, objlat, distance, scope);
            List <PlaceViewModel> li = new List <PlaceViewModel>();

            foreach (Place p in places)
            {
                PlaceViewModel pvm = new PlaceViewModel();
                pvm.Id          = p.Id;
                pvm.Name        = p.Name;
                pvm.Description = p.Description;
                pvm.Longitude   = p.Longitude;
                pvm.Latitude    = p.Latitude;
                pvm.ZoomSize    = p.ZoomSize;
                pvm.Address     = p.Address;
                pvm.ServeStatus = p.ServeStatus;
                pvm.PlaceKindId = p.PlaceKindId;
                pvm.DateCreate  = p.DateCreate;
                pvm.RootPlaceId = p.RootPlaceId;
                pvm.RatingStar  = p.RatingStar;
                pvm.NofSearch   = p.NofSearch;
                pvm.Poppular    = p.Poppular;
                pvm.TimeOpen    = p.TimeOpen;
                pvm.TimeClose   = p.TimeClose;
                pvm.LastConfirm = p.LastConfirm;
                pvm.Facebook    = p.Facebook;
                pvm.Instagram   = p.Instagram;
                pvm.PageUrl     = p.PageUrl;
                pvm.UserId      = p.UserId;
                pvm.PhoneNumber = p.PhoneNumber;
                pvm.isEnable    = p.isEnable;
                li.Add(pvm);
            }
            return(Ok(li));
        }
Пример #5
0
        //api/Place/GetPlacesByPopular
        public IHttpActionResult GetPlacesByPopular(string search)
        {
            List <Place>          places = _PlaceService.SearchPlacesByPopular(convertToUnSign3(search));
            List <PlaceViewModel> li     = new List <PlaceViewModel>();

            foreach (Place p in places)
            {
                PlaceViewModel pvm = new PlaceViewModel();
                pvm.Id          = p.Id;
                pvm.Name        = p.Name;
                pvm.Description = p.Description;
                pvm.Longitude   = p.Longitude;
                pvm.Latitude    = p.Latitude;
                pvm.ZoomSize    = p.ZoomSize;
                pvm.Address     = p.Address;
                pvm.ServeStatus = p.ServeStatus;
                pvm.PlaceKindId = p.PlaceKindId;
                pvm.DateCreate  = p.DateCreate;
                pvm.RootPlaceId = p.RootPlaceId;
                pvm.RatingStar  = p.RatingStar;
                pvm.NofSearch   = p.NofSearch;
                pvm.Poppular    = p.Poppular;
                pvm.TimeOpen    = p.TimeOpen;
                pvm.TimeClose   = p.TimeClose;
                pvm.LastConfirm = p.LastConfirm;
                pvm.Facebook    = p.Facebook;
                pvm.Instagram   = p.Instagram;
                pvm.PageUrl     = p.PageUrl;
                pvm.UserId      = p.UserId;
                pvm.PhoneNumber = p.PhoneNumber;
                pvm.isEnable    = p.isEnable;
                li.Add(pvm);
            }
            return(Ok(li));
        }
Пример #6
0
        //api/Place/
        public IHttpActionResult GetPlaceById(int id)
        {
            Place          p   = _PlaceService.GetPlace(id);
            PlaceViewModel pvm = new PlaceViewModel();

            pvm.Id          = p.Id;
            pvm.Name        = p.Name;
            pvm.Description = p.Description;
            pvm.Longitude   = p.Longitude;
            pvm.Latitude    = p.Latitude;
            pvm.ZoomSize    = p.ZoomSize;
            pvm.Address     = p.Address;
            pvm.ServeStatus = p.ServeStatus;
            pvm.PlaceKindId = p.PlaceKindId;
            pvm.DateCreate  = p.DateCreate;
            pvm.RootPlaceId = p.RootPlaceId;
            pvm.RatingStar  = p.RatingStar;
            pvm.NofSearch   = p.NofSearch;
            pvm.Poppular    = p.Poppular;
            pvm.TimeOpen    = p.TimeOpen;
            pvm.TimeClose   = p.TimeClose;
            pvm.LastConfirm = p.LastConfirm;
            pvm.Facebook    = p.Facebook;
            pvm.Instagram   = p.Instagram;
            pvm.PageUrl     = p.PageUrl;
            pvm.UserId      = p.UserId;
            pvm.PhoneNumber = p.PhoneNumber;
            pvm.isEnable    = p.isEnable;
            return(Ok(pvm));
        }
Пример #7
0
        public IHttpActionResult Create(PlaceViewModel place)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            Place p = new Place();

            p.Address     = place.Address;
            p.Description = place.Description;
            p.Facebook    = place.Facebook;
            p.Instagram   = place.Instagram;
            p.Longitude   = place.Longitude;
            p.Latitude    = place.Latitude;
            p.Name        = place.Name;
            p.NofSearch   = place.NofSearch;
            p.PageUrl     = place.PageUrl;
            p.PhoneNumber = place.PhoneNumber;
            p.PlaceKindId = place.PlaceKindId;
            p.Poppular    = place.Poppular;
            p.RootPlaceId = place.RootPlaceId;
            p.RatingStar  = place.RatingStar;
            p.ServeStatus = place.ServeStatus;
            p.TimeOpen    = place.TimeOpen;
            p.TimeClose   = place.TimeClose;
            p.UserId      = place.UserId;
            p.ZoomSize    = place.ZoomSize;
            p.DateCreate  = DateTime.Now;
            p.LastConfirm = DateTime.Now;
            p.isEnable    = place.isEnable;
            _PlaceService.CreatePlace(p);
            return(Ok());
        }
Пример #8
0
        // api/Place/Update
        public IHttpActionResult Update(PlaceViewModel p)
        {
            var Place = _PlaceService.GetPlace(p.Id);

            if (Place != null)
            {
                Place.Address     = p.Address;
                Place.Description = p.Description;
                Place.Facebook    = p.Facebook;
                Place.Instagram   = p.Instagram;
                Place.Longitude   = p.Longitude;
                Place.Latitude    = p.Latitude;
                Place.Name        = p.Name;
                Place.NofSearch   = p.NofSearch;
                Place.PageUrl     = p.PageUrl;
                Place.PhoneNumber = p.PhoneNumber;
                Place.PlaceKindId = p.PlaceKindId;
                Place.Poppular    = p.Poppular;
                Place.RootPlaceId = p.RootPlaceId;
                Place.RatingStar  = p.RatingStar;
                Place.ServeStatus = p.ServeStatus;
                Place.TimeOpen    = p.TimeOpen;
                Place.TimeClose   = p.TimeClose;
                Place.LastConfirm = DateTime.Now;
                Place.isEnable    = p.isEnable;
                _PlaceService.EditPlace(Place);
            }
            return(Ok());
        }
Пример #9
0
        public PlaceView(PlaceModel place)
        {
            InitializeComponent();
            BindingContext = new PlaceViewModel(this, place);
            AddPin(place);

            var tapGestureRecognizer = new TapGestureRecognizer();

            tapGestureRecognizer.Tapped += async(s, e) => {
                await slMaps.FadeTo(0, 250, Easing.Linear);

                slMaps.IsVisible        = false;
                slDescription.IsVisible = true;
                await slDescription.FadeTo(1, 250, Easing.Linear);
            };
            lblDescription.GestureRecognizers.Add(tapGestureRecognizer);

            tapGestureRecognizer         = new TapGestureRecognizer();
            tapGestureRecognizer.Tapped += async(s, e) => {
                await slDescription.FadeTo(0, 250, Easing.Linear);

                slDescription.IsVisible = false;
                slMaps.IsVisible        = true;
                await slMaps.FadeTo(1, 250, Easing.Linear);
            };
            lblMap.GestureRecognizers.Add(tapGestureRecognizer);
        }
Пример #10
0
 public DeleteModalWindow(PlaceViewModel placeViewModel)
 {
     this.placeViewModel = placeViewModel;
     InitializeComponent();
     SwitchLanguage();
     ChangeTheme();
 }
        public IActionResult Update(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            List <CountryViewModel> countryModel = new List <CountryViewModel>();

            countryService.GetAllCountries().ToList().ForEach(u =>
            {
                CountryViewModel _country = new CountryViewModel
                {
                    Id   = u.Id,
                    Name = u.Name
                };
                countryModel.Add(_country);
            });
            ViewData["Country"] = countryModel.ToList();

            Place _place = placeService.GetPlace((long)id);

            PlaceViewModel placeModel = new PlaceViewModel
            {
                Id      = _place.Id,
                Name    = _place.Name,
                Address = _place.Address,
                Rating  = _place.Rating,
                Picture = _place.Picture,
                Country = _place.Country.Name
            };

            return(View(placeModel));
        }
        public ActionResult ViewDetail(int?id)
        {
            var _placeService = this.Service <IPlaceService>();
            var entity        = _placeService.FirstOrDefaultActive(p => p.Id == id.Value &&
                                                                   (p.Status == (int)PlaceStatus.Active || p.Status == (int)PlaceStatus.Repairing));

            if (entity == null)
            {
                return(RedirectToAction("PageNotFound", "Errors"));
            }
            var place = new PlaceViewModel(entity);
            var _placeImageService         = this.Service <IPlaceImageService>();
            var _placeFieldService         = this.Service <IFieldService>();
            var _placeEventService         = this.Service <IEventService>();
            var _fieldTypeService          = this.Service <IFieldTypeService>();
            var _sportService              = this.Service <ISportService>();
            List <PlaceImage> placeImages  = _placeImageService.GetActive(p => p.PlaceId == id.Value).ToList();
            List <Field>      placeFields  = _placeFieldService.GetActive(p => p.PlaceId == id.Value).ToList();
            List <Event>      placeEvents  = _placeEventService.GetActive(p => p.PlaceId == id.Value).ToList();
            List <FieldType>  fieldTypes   = _fieldTypeService.GetActive().ToList();
            Event             lastestEvent = new Event();

            if (placeEvents != null && placeEvents.Count > 0)
            {
                lastestEvent         = placeEvents.First();
                ViewBag.lastestEvent = lastestEvent;
            }
            ViewBag.placeImages = placeImages;
            ViewBag.placeFields = placeFields;
            ViewBag.PlaceStatus = Utils.GetEnumDescription((PlaceStatus)place.Status);

            var list = _placeFieldService.GetActive(p => p.PlaceId == id.Value).
                       Join(_fieldTypeService.GetActive(),
                            f => f.FieldTypeId, ft => ft.Id,
                            (f, ft) => new
            {
                fieldID   = f.Id,
                fieldName = f.Name,
                sportId   = ft.SportId,
                fieldType = f.FieldType.Name
            }).Join(_sportService.GetActive(),
                    a => a.sportId, p => p.Id,
                    (a, p) => new
            {
                fieldID   = a.fieldID,
                fieldName = a.fieldName,
                sport     = p.Name,
                fieldType = a.fieldType
            }).Select(p => new FieldSportViewModel
            {
                FieldId   = p.fieldID,
                FieldName = p.fieldName,
                Sport     = p.sport,
                FieldType = p.fieldType
            }).ToList();

            ViewBag.fieldSport = list;
            return(View(place));
        }
Пример #13
0
        //Destroy Place by ViewModel
        public IHttpActionResult Destroy(PlaceViewModel p)
        {
            var place = _PlaceService.GetPlace(p.Id);

            place.isEnable = false;
            _PlaceService.EditPlace(place);
            return(Ok());
        }
Пример #14
0
        public ActionResult Edit(int id)
        {
            PlaceClient    client = new PlaceClient();
            PlaceViewModel CVM    = new PlaceViewModel();

            CVM.Place = client.Find(id);
            return(View("Edit", CVM.Place));
        }
Пример #15
0
        public IHttpActionResult Post(PlaceViewModel vm)
        {
            var userId = User.Identity.GetUserId();

            _repo.LikePlaceSave(vm, userId);

            return(Ok("It worked"));
        }
        private PlaceViewModel InitModel()
        {
            var model = new PlaceViewModel();

            model.HasChanges = _cartoPlaceService.HasChanges;

            return(model);
        }
        public ActionResult PlaceInDb(PlaceViewModel place)
        {
            var      mapper = new MapperConfiguration(cfg => cfg.CreateMap <PlaceViewModel, PlaceDTO>()).CreateMapper();
            PlaceDTO result = mapper.Map <PlaceViewModel, PlaceDTO>(place);
            var      res    = _placeService.IsPlaceConsist(result);

            return(Ok(res));
        }
Пример #18
0
        private void OnProvinceTapped(object sender, ItemTappedEventArgs e)
        {
            PlaceViewModel prov = (PlaceViewModel)e.Item;

            MessagingCenter.Send <FindDocProvince, string>(this, "PROVINCE", prov.Place);
            ProList.SelectedItem = null;
            Navigation.PushAsync(new FindDocCity(prov.Place));
        }
Пример #19
0
        // Code to execute when the application is launching (eg, from Start)
        // This code will not execute when the application is reactivated
        private void Application_Launching(object sender, LaunchingEventArgs e)
        {
            //string startPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase);// System.IO.Directory.GetCurrentDirectory();
            //var filepath = startPath + "\\" + "Database.sdf";

            // Specify the local database connection string.
            string DBConnectionString = "Data Source=isostore:/Places.sdf";

            // Create the data context.
            //string DBConnectionString = "Data Source = 'appdata:/mydb.sdf'; File Mode = read only;";
            //https://msdn.microsoft.com/en-us/library/windows/apps/hh286411(v=vs.105).aspx

            // Create the database if it does not exist.
            using (PlaceDataContext db = new PlaceDataContext(DBConnectionString))
            {
                if (db.DatabaseExists() == false)
                {
                    // Create the local database.
                    db.CreateDatabase();

                    // Prepopulate the places.
                    db.Places.InsertOnSubmit(new PlaceDetails {
                        PlaceName = "Miejsce nr 1"
                    });                                                                        // Jakiś tam opis tego miejsca | Miejscowość, ulica | /PictureOfPlaces/p1.jpg

                    // Save categories to the database.
                    db.SubmitChanges();

                    // Set the new database version.
                    DatabaseSchemaUpdater dbUpdater = db.CreateDatabaseSchemaUpdater();
                    dbUpdater.DatabaseSchemaVersion = APP_VERSION;
                    dbUpdater.Execute();
                }
                else
                {
                    // Check whether a database update is needed.
                    DatabaseSchemaUpdater dbUpdater = db.CreateDatabaseSchemaUpdater();

                    /*if (dbUpdater.DatabaseSchemaVersion < APP_VERSION)
                     * {
                     *  // Add the Priority column (added in version 2).
                     *  dbUpdater.AddColumn<ToDoItem>("Priority");
                     *
                     *  // Add the new database version.
                     *  dbUpdater.DatabaseSchemaVersion = 2;
                     *
                     *  // Perform the database update in a single transaction.
                     *  dbUpdater.Execute();
                     * }*/
                }
            }

            // Create the ViewModel object.
            viewModel = new PlaceViewModel(DBConnectionString);

            // Query the local database and load observable collections.
            viewModel.LoadCollectionsFromDatabase();
        }
Пример #20
0
        public override void Edit(object selectedItem)
        {
            DataRowView     item        = (DataRowView)selectedItem;
            PlaceViewModel  place       = Mapping.Mapper.Map <PlaceViewModel>(item);
            EditModalWindow modalWindow = new EditModalWindow(place);

            _ = modalWindow.ShowDialog();
            DataGridControl.InformAboutStatus(modalWindow.OperationStatus);
        }
Пример #21
0
        public IActionResult OrderContinue(int?id, string date)
        {
            var      plac    = new PlaceViewModel(id.Value, date);
            DateTime dateTim = DateTime.Parse(date);

            plac.plac = _orderService.GetSeats(dateTim, id.Value);

            return(View("Order", plac));
        }
        public override void Edit(object selectedItem, double height = 0, double width = 0)
        {
            DataRowView    item  = (DataRowView)selectedItem;
            PlaceViewModel place = Mapping.Mapper.Map <PlaceViewModel>(item);
            EditModal      modal = new EditModal(place);

            WindowHelper.SetModal(modal, height, width);
            modal.ShowDialog();
        }
 public EditModalWindow(PlaceViewModel model)
 {
     placeViewModel = model;
     InitializeComponent();
     InitalizeComboBoxes();
     SwitchLanguage();
     ChangeTheme();
     PopulateContent();
 }
        // GET: /Administration/Places/Create
        public ActionResult Create()
        {
            PlaceViewModel place = new PlaceViewModel();


            place.EatTypeItems   = GetEatTypeItems();
            place.PriceTypeItems = GetPriceTypeItems();

            return(View(place));
        }
        public override void Delete(object selectedItem, double height = 0, double width = 0)
        {
            DataRowView    item  = (DataRowView)selectedItem;
            PlaceViewModel place = Mapping.Mapper.Map <PlaceViewModel>(item);

            Window deleteModal = new DeleteModal(place);

            WindowHelper.CenterWindow(deleteModal, height, width);
            deleteModal.ShowDialog();
        }
Пример #26
0
 public async Task AssignProperties(Place place, PlaceViewModel viewModel)
 {
     place.Title       = viewModel.Title;
     place.Address     = viewModel.Address;
     place.Coordinates = new Coordinates
     {
         Latitude  = viewModel.Coordinates.Latitude,
         Longitude = viewModel.Coordinates.Longitude
     };
 }
        private PlaceViewModel StringToViewModel(string toParse)
        {
            if (!string.IsNullOrEmpty(toParse))
            {
                PlaceHitchWikiModel hitchModel = Newtonsoft.Json.JsonConvert.DeserializeObject <PlaceHitchWikiModel>(toParse);
                PlaceViewModel      toReturn   = new PlaceViewModel(hitchModel);
                return(toReturn);
            }

            return(null);
        }
Пример #28
0
        private void OnProvinceTapped(object sender, ItemTappedEventArgs e)
        {
            PlaceViewModel city = (PlaceViewModel)e.Item;

            MessagingCenter.Send <FindDocCity, string>(this, "CITY", city.Place);
            CityList.SelectedItem = null;
            IReadOnlyList <Page> navStack = Navigation.NavigationStack;

            Navigation.RemovePage(navStack[navStack.Count - 2]);
            Navigation.PopAsync();
        }
Пример #29
0
 /// <summary>
 ///     Mapping new option view model based on place model and voter id
 /// </summary>
 /// <param name="place">Place view model</param>
 /// <param name="userId">Id of a voter</param>
 /// <returns>New option view model</returns>
 public static OptionViewModel MapToOptionViewModel(PlaceViewModel place, string userId)
 {
     return(new OptionViewModel()
     {
         Id = place.Id,
         Title = place.Venue.Name,
         Desc = place.Venue.AddressInfo,
         UsersVote = MapToUsersVoteModel(place.VotesForPlace, userId),
         Votes = MapToVotesViewModel(place.VotesForPlace)
     });
 }
 public SummaryBookingViewModel(PlaceViewModel departure, PlaceViewModel destionation,
                                int adult, int child, DateTime departureDate, bool isReturn)
 {
     //Customer = customer;
     Departure   = departure;
     Destination = destionation;
     Adult       = adult;
     Child       = child;
     DeparDate   = departureDate;
     IsReturn    = isReturn;
     Tax         = Common.TAX;
 }
Пример #31
0
 /// <summary>
 ///     Called when <see cref="CommandUpdatePlace" /> is executed.
 /// </summary>
 /// <param name="pushpin"> The pushpin view model. </param>
 private void OnUpdatePlace(PlaceViewModel pushpin)
 {
     _data.GetPlaceDetails(pushpin.Data);
 }
Пример #32
0
 /// <summary>
 ///     Called when <see cref="CommandDeletePlace" /> is executed.
 /// </summary>
 private void OnDeletePlace(PlaceViewModel vm)
 {
     _data.RemovePlace(vm.Data);
 }
Пример #33
0
 /// <summary>
 ///     Mapping new option view model based on place model and voter id
 /// </summary>
 /// <param name="place">Place view model</param>
 /// <param name="userId">Id of a voter</param>
 /// <returns>New option view model</returns>
 public static OptionViewModel MapToOptionViewModel(PlaceViewModel place, string userId)
 {
     return new OptionViewModel()
     {
         Id = place.Id,
         Title = place.Venue.Name,
         Desc = place.Venue.AddressInfo,
         UsersVote = MapToUsersVoteModel(place.VotesForPlace, userId),
         Votes = MapToVotesViewModel(place.VotesForPlace)
     };
 }