Ejemplo n.º 1
0
        public async Task <IActionResult> Create([Bind("BuildingId,FloorId,PlaceId,PlaceName,Flg,Rtp,Rtt")] PlaceModel placeModel)
        {
            ViewBag.BuildingName = _context.Buildings.Find(placeModel.BuildingId).BuildingName;
            ViewBag.FloorName    = _context.Floors.Find(placeModel.BuildingId, placeModel.FloorId).FloorName;
            PlaceModel placeIdExist = _context.Places.Find(placeModel.BuildingId, placeModel.FloorId, placeModel.PlaceId);

            if (placeIdExist != null)
            {
                ModelState.AddModelError("PlaceId", "代號重複");
                return(View(placeModel));
            }
            // Get Login User's details.
            var ur = _userRepo.Find(u => u.UserName == this.User.Identity.Name).FirstOrDefault();

            // Set values.
            placeModel.Rtp = ur.Id;
            placeModel.Rtt = DateTime.Now;

            if (ModelState.IsValid)
            {
                _context.Add(placeModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index", new { buildingId = placeModel.BuildingId, floorId = placeModel.FloorId }));
            }
            return(View(placeModel));
        }
Ejemplo n.º 2
0
 public ActionResult Create(PlaceModel collection)
 {
     placesCollection = _dbcontext.database.GetCollection <PlaceModel>("Places");
     placesCollection.InsertOne(collection);
     Console.WriteLine("Insert");
     return(RedirectToAction("Index"));
 }
Ejemplo n.º 3
0
        public LParkingPage(UserModel user, PlaceModel Place)
        {
            InitializeComponent();

            Global.Intance.masterDetailPage = this;
            _UserProfileModel = user;
            PlaceSelect       = Place;



            if (PlaceSelect.TypePlace == 0)
            {
                lblTypePlace.Text = "LParking";
            }
            if (PlaceSelect.TypePlace == 1)
            {
                lblTypePlace.Text = "Trạm cân";
            }


            Global.Intance.SerIpAdressLParking = PlaceSelect.IpAddress;
            Global.Intance.SerPortAPILParking  = PlaceSelect.PortAPI.ToString();


            lblNamePlace.Text = PlaceSelect.Name;
            NavigationPage.SetHasNavigationBar(this, false);

            CheckUserLogin();//Kiểm tra quyền
        }
Ejemplo n.º 4
0
        public ActionResult Delete(string id = "")
        {
            Logger.Debug("Inside Place Controller- Delete");
            try
            {
                if (Session["OrganizationGUID"] != null)
                {
                    PlaceModel place = new PlaceModel();
                    place.PlaceGUID = id;
                    _IPlaceRepository.DeletePlace(new Guid(place.PlaceGUID));
                    //_IPlaceRepository.Save();
                    _IPeopleRepository.DeletePeopleByPlaceGUID(new Guid(place.PlaceGUID));
                    _IMarketRepository.DeleteMarketByOwnerGUID(new Guid(place.PlaceGUID));

                    return(RedirectToAction("Index"));
                }
                else
                {
                    return(RedirectToAction("SessionTimeOut", "User"));
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex.Message);
                return(RedirectToAction("Index"));
            }
        }
 private void addPlaceButtonClick()
 {
     if (PlaceNameData != null && PlaceInfoData != null)
     {
         PlaceModel temp = new PlaceModel();
         temp.Name        = PlaceNameData;
         temp.Information = PlaceInfoData;
         temp.DateStart   = PlaceDSData.ToString("dd/MM/yyyy");
         temp.DateFinish  = PlaceDFData.ToString("dd/MM/yyyy");
         PlaceList.Add(temp);
     }
     else
     {
         MessageBox.Show("Vui lòng nhập đủ thông tin trước khi thêm!!!");
     }
     PlaceNameData = null;
     PlaceInfoData = null;
     PlaceDSData   = DateTime.Now;
     PlaceDFData   = DateTime.Now;
     OnPropertyChanged(nameof(PlaceList));
     OnPropertyChanged(nameof(PlaceNameData));
     OnPropertyChanged(nameof(PlaceInfoData));
     OnPropertyChanged(nameof(PlaceDSData));
     OnPropertyChanged(nameof(PlaceDFData));
 }
Ejemplo n.º 6
0
        public void AddPlaceForTrip(object o)
        {
            var           parameter = (object[])o;
            List <string> Data      = new List <string>();

            foreach (var x in parameter)
            {
                if (x.GetType().Equals(typeof(DateTime)))
                {
                    DateTime y = (DateTime)x;
                    Data.Add(y.ToString("dd/MM/yyyy"));
                }
                else
                {
                    Data.Add(x.ToString());
                }
            }
            PlaceModel temp = new PlaceModel();

            temp.Name        = Data[0];
            temp.Information = Data[1];
            temp.DateStart   = Data[2];
            temp.DateFinish  = Data[3];
            Trip.AddPlace(temp);
            PlaceList.Add(temp);
            OnPropertyChanged(nameof(Trip));
        }
Ejemplo n.º 7
0
        public async Task <IHttpActionResult> UpdatePlace(int clientId, [FromBody] PlaceModel model)
        {
            var userId = GetUserId();
            var place  = await _placeManager.UpdateAsync(model, clientId, userId);

            return(Ok(place));
        }
Ejemplo n.º 8
0
        private void addPlace_Clicked(object sender, EventArgs e)
        {
            PlaceModel placeModel = new PlaceModel();
            string     flag       = "AddPlace";

            Navigation.PushAsync(new AddPlacePage(placeModel, userProfileModel, flag));
        }
        /// <summary>
        /// Inserts object into Oracle DataBase and returns its ID
        /// </summary>
        /// <param name="place"></param>
        /// <returns></returns>
        public int insertPlaceToDBReturnItsID(PlaceModel place)
        {
            int output = -1;

            try
            {
                using (OracleConnection connection = new OracleConnection(OracleSQLConnector.GetConnectionString()))
                {
                    connection.Open();
                    OracleCommand cmd = new OracleCommand();
                    cmd.CommandText = String.Format(
                        "INSERT INTO place_table(city, postcode, street, description, trainer_table_id) VALUES('{0}', '{1}', '{2}', '{3}', {4}) RETURNING id INTO :id",
                        place.getCity(), place.getPostCode(), place.getStreet(), place.getDescription(), GlobalClass.getTrainerID());
                    cmd.Connection = connection;

                    cmd.Parameters.Add(new OracleParameter
                    {
                        ParameterName = ":id",
                        OracleDbType  = OracleDbType.Int32,
                        Direction     = ParameterDirection.Output
                    });
                    cmd.ExecuteNonQuery();
                    String outputStr = cmd.Parameters[":id"].Value.ToString();
                    output = Convert.ToInt32(outputStr);
                }
            }catch
            {
            }
            return(output);
        }
        /// <summary>
        /// Sends object to Oracle DataBase for an update.
        /// </summary>
        /// <param name="place"></param>
        /// <returns></returns>
        public bool updatedPlaceToDataBase(PlaceModel place, int currentlySelectedItemID)
        {
            try
            {
                using (OracleConnection connection = new OracleConnection(OracleSQLConnector.GetConnectionString()))
                {
                    connection.Open();
                    OracleCommand cmd;
                    string        sql = String.Format(
                        "UPDATE place_table SET city = '{0}', postcode = '{1}', street = '{2}', description = '{3}' WHERE id = {4}",
                        place.getCity(), place.getPostCode(), place.getStreet(), place.getDescription(), currentlySelectedItemID);
                    cmd             = new OracleCommand(sql, connection);
                    cmd.CommandType = CommandType.Text;

                    int rowsUpdated = cmd.ExecuteNonQuery();
                    if (rowsUpdated == 0)
                    {
                        return(false);
                    }
                    else
                    {
                        return(true);
                    }
                }
            }catch
            {
                return(false);
            }
        }
Ejemplo n.º 11
0
        public async Task <IActionResult> Edit([Bind("BuildingId,FloorId,PlaceId,PlaceName,Flg,Rtp,Rtt")] PlaceModel placeModel)
        {
            ViewBag.BuildingName = _context.Buildings.Find(placeModel.BuildingId).BuildingName;
            ViewBag.FloorName    = _context.Floors.Find(placeModel.BuildingId, placeModel.FloorId).FloorName;
            // Get Login User's details.
            var ur = _userRepo.Find(u => u.UserName == this.User.Identity.Name).FirstOrDefault();

            // Set values.
            placeModel.Rtp = ur.Id;
            placeModel.Rtt = DateTime.Now;

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(placeModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PlaceModelExists(placeModel.BuildingId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index", new { buildingId = placeModel.BuildingId, floorId = placeModel.FloorId }));
            }
            return(View(placeModel));
        }
Ejemplo n.º 12
0
        private void MyPlaces_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            //caster value som Placemodel
            PlaceModel myValue = e.CurrentSelection.FirstOrDefault() as PlaceModel;

            Application.Current.MainPage.Navigation.PushAsync(new MapPage(myValue));
        }
Ejemplo n.º 13
0
        public static List <PlaceModel> GetPlace()
        {
            var placeModelsList = new List <PlaceModel>();
            var sessionFactory  = SessionFactory.CreateSessionFactory();

            using (var session = sessionFactory.OpenSession())
            {
                using (session.BeginTransaction())
                {
                    var PlaceCreate = session.CreateCriteria(typeof(Place))
                                      .List <Place>();

                    foreach (var pla in PlaceCreate)
                    {
                        var temp = new PlaceModel()
                        {
                            Id              = pla.Id,
                            Street          = pla.Street,
                            PlacePopulation = pla.PlacePopulation,
                            CityModel       = new CityModel {
                                Id = pla.City.Id
                            },
                            BuildingModel = new BuildingModel {
                                Id = pla.Building.Id
                            }
                        };

                        placeModelsList.Add(temp);
                    }

                    return(placeModelsList);
                }
            }
        }
Ejemplo n.º 14
0
 private PlaceViewModel ModelToView(PlaceModel model)
 {
     if (model == null)
     {
         return(null);
     }
     return(new PlaceViewModel
     {
         Id = model.Id,
         Code = model.Code,
         Name = model.Name,
         SubscriberId = model.SubscriberId,
         PlaceGroupId = model.PlaceGroup.Id,
         PlaceGroup = new PlaceGroupViewModel
         {
             Id = model.PlaceGroup.Id,
             Code = model.PlaceGroup.Code,
             Name = model.PlaceGroup.Name,
             Enabled = model.PlaceGroup.Enabled,
             SubscriberId = model.PlaceGroup.SubscriberId,
             Building = model.PlaceGroup.Building
         },
         Infrastructure = model.Infrastructure,
         LocationDescription = model.LocationDescription,
         MaxUsers = model.MaxUsers,
         OptionalInfrastructure = model.OptionalInfrastructure
     });
 }
Ejemplo n.º 15
0
        public ActionResult List()
        {
            PlaceModel model = new PlaceModel();

            model.Places = placeService.GetPlaces();
            return(PartialView("_List", model));
        }
Ejemplo n.º 16
0
        public async Task <ContentResponse <PlaceModel> > CreatePlace(PlaceModel placeModel)
        {
            if (_networkService.IsConnected())
            {
                using (HttpClient client = new HttpClient())
                {
                    client.DefaultRequestHeaders.Add("ZUMO-API-VERSION", "2.0.0");

                    var url = AppConfigurations.ApiRoot + AppConfigurations.GetAllPlacesEndpoint;

                    var body   = new StringContent(JsonConvert.SerializeObject(placeModel), Encoding.UTF8, "application/json");
                    var result = await client.PostAsync(url, body);

                    string data = await result.Content.ReadAsStringAsync();

                    return(new ContentResponse <PlaceModel>()
                    {
                        HttpResponse = result,
                        Data = JsonConvert.DeserializeObject <PlaceModel>(data)
                    });
                }
            }
            else
            {
                return(new ContentResponse <PlaceModel>()
                {
                    HttpResponse = new HttpResponseMessage(HttpStatusCode.RequestTimeout)
                });
            }
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Helper method to sort and set the firt image link.
        /// </summary>
        public void SortAndSetFirst()
        {
            // Set the first image link. Assumes main image is manually set to the first image in
            // Gramps if we need it to be, e.g. Citations.
            PlaceModel tempModel = new PlaceModel();

            if (Count > 0)
            {
                // Step through each citationmodel hlink in the collection
                for (int i = 0; i < Count; i++)
                {
                    tempModel = DV.PlaceDV.PlaceData.GetModelFromHLink(this[i]);

                    if (tempModel.HomeImageHLink.LinkToImage)
                    {
                        FirstHLinkHomeImage = tempModel.HomeImageHLink;
                        break;
                    }
                }

                // Sort the collection
                List <HLinkPlaceModel> t = this.OrderBy(HLinkCitationModel => HLinkCitationModel.DeRef.GetDefaultText).ToList();

                Items.Clear();

                foreach (HLinkPlaceModel item in t)
                {
                    Items.Add(item);
                }
            }
        }
Ejemplo n.º 18
0
        static public async Task <PlaceModel> CreatePlaceModelAsync(Place source, bool includeAllFields = false)
        {
            var model = new PlaceModel()
            {
                PlaceID        = source.place_id,
                CustomerID     = source.customer_id,
                Address        = source.addr,
                Address2       = source.addr2,
                City           = source.city,
                Region         = source.region,
                CountryCode    = source.country_cd,
                PostalCode     = source.postalcode,
                Phone          = source.place_tel_no,
                InstallDate    = source.install_dt,
                DelYn          = source.del_yn,
                CreatedOn      = source.reg_dt,
                LastModifiedOn = source.upd_dt
            };

            if (source.Customer != null)
            {
                model.Customer = await CustomerService.CreateCustomerModelAsync(source.Customer, includeAllFields);
            }
            return(model);
        }
Ejemplo n.º 19
0
        public PlaceSuggestModel parseData(String json)
        {
            JavaScriptSerializer js                   = new JavaScriptSerializer();
            PlaceModel           placeModel           = js.Deserialize <PlaceModel>(json);
            PlaceSuggestModel    getPlaceSuggestModel = null;


            foreach (PlaceModel.ResultModel result in placeModel.results)
            {
                string jsonData = place_suggest(result.geometry.location.lat, result.geometry.location.lng);
                getPlaceSuggestModel = parseDataToShowSugg(jsonData);
                break;


                try
                {
                    //Response.Write(result.photos[0].photo_reference);
                    ViewBag.place_photo = result.photos[0].photo_reference;
                    //func
                }
                catch (Exception e)
                {
                    Response.Write(e.Message);
                }
            }
            return(getPlaceSuggestModel);
        }
Ejemplo n.º 20
0
        protected async Task <PlaceModel> InsertPlaceAsync(bool defaultAuthentication = true)
        {
            var place = new PlaceModel
            {
                Address     = "address",
                Description = "description",
                Latitude    = 1,
                Longitude   = 1,
                Phone       = "123456",
                Location    = new LocationModel {
                    Id = 1
                },
                GuestsAllowed = 1
            };

            var response = await this.PostAsync <BaseModel>(
                "/api/v1/places",
                place,
                defaultAuthentication : defaultAuthentication,
                removeAuthentication : false);

            place.Id = response.Content.Id;

            return(place);
        }
Ejemplo n.º 21
0
        public HttpResponseMessage GetCurrentUserClosestPlaces(string sessionKey)
        {
            ICollection <PlaceModel> allPlaceModels = new List <PlaceModel>();

            var allPlaces = placesRepo.All().ToList();

            foreach (Place currentPlace in allPlaces)
            {
                PlaceModel currentModelPlace = new PlaceModel(currentPlace);

                allPlaceModels.Add(currentModelPlace);
            }

            User currentUser = usersRepo.All().Where(u => u.SessionKey == sessionKey).FirstOrDefault();

            if (currentUser == null)
            {
                return(this.Request.CreateErrorResponse(HttpStatusCode.NotFound, "There isn't such logged user."));
            }

            ICollection <PlaceModel> resultPlaceModels = new List <PlaceModel>();

            foreach (Place currentPlace in allPlaces)
            {
                if (Math.Abs(currentUser.Longitude - currentPlace.Longitude) <= 1 &&
                    Math.Abs(currentUser.Latitude - currentPlace.Latitude) <= 1)
                {
                    PlaceModel currentPlaceModel = new PlaceModel(currentPlace);

                    resultPlaceModels.Add(currentPlaceModel);
                }
            }

            return(this.Request.CreateResponse(HttpStatusCode.OK, resultPlaceModels));
        }
Ejemplo n.º 22
0
        public async Task <PlaceModel> UpdatePlaceAsync(PlaceModel place)
        {
            var user = await userRepository.GetUser();

            var placeForUpdate = await placeRepository.GetAsync(place.Id);

            placeForUpdate.ModifiedDate       = DateTime.Now;
            placeForUpdate.Name               = place.Name;
            placeForUpdate.StatusId           = place.StatusId;
            placeForUpdate.StreetAddress      = place.StreetAddress;
            placeForUpdate.Latitude           = place.Latitude;
            placeForUpdate.Longitude          = place.Longitude;
            placeForUpdate.WebSite            = place.WebSite;
            placeForUpdate.Phone              = place.Phone;
            placeForUpdate.CellPhone          = place.CellPhone;
            placeForUpdate.Comment            = place.Comment;
            placeForUpdate.ContactName        = place.ContactName;
            placeForUpdate.ContactTitle       = place.ContactTitle;
            placeForUpdate.Email              = place.Email;
            placeForUpdate.TenantId           = user.TenantId;
            placeForUpdate.LastModifierUserId = requestIdentityProvider.UserId;
            await placeRepository.SaveChangesAsync();

            return(mapper.Map <PlaceModel>(placeForUpdate));
        }
Ejemplo n.º 23
0
    private WeekWeatherAnalysis Search(PlaceModel province, PlaceModel city, PlaceModel district)
    {
        WeekWeatherAnalysis detail = new WeekWeatherAnalysis(province.ID, city.ID, district.ID);

        detail.HandleWeather();
        return(detail);
    }
Ejemplo n.º 24
0
 public long Place(string ticket, PlaceModel placeModel)
 {
     lock (mutex)
     {
         var ctx = GetContext(ticket);
         if (ctx != null &&
             chessboard != null &&
             !chessboard.GameOver &&
             ctx.Name == chessboard.CurrentPlayer)
         {
             var figure = chessboard.Get(placeModel.FromRow, placeModel.FromColumn);
             if (figure != null && figure.Color == chessboard.CurrentColor)
             {
                 foreach (var move in chessboard.GetAllMoves(figure, chessboard.Check))
                 {
                     if (move.Item1 == placeModel.ToRow && move.Item2 == placeModel.ToColumn)
                     {
                         if (IsComputerGame())
                         {
                             SendChessEngineUserMove(figure, placeModel);
                         }
                         // ok to move
                         if (chessboard.Place(figure, placeModel.ToRow, placeModel.ToColumn))
                         {
                             chessboard.UpdateState();
                             stateChanged = DateTime.UtcNow;
                         }
                         break;
                     }
                 }
             }
         }
         return(GetStateChanged());
     }
 }
Ejemplo n.º 25
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);
        }
Ejemplo n.º 26
0
        // GET: /places/12/united-kingdom/2
        public ActionResult Show(int id, int?page)
        {
            var m = new PlaceModel();
            var p = SVD.Controller.Instance.PlacesController.GetPlace(id);

            if (p == null)
            {
                Helpers.AddPageMessage("No such place found, sorry!", PageMessageType.Error);
                return(RedirectToAction("Index", "Home"));
            }

            var currentPage = page ?? 1;
            var status      = new[] { VehicleStatus.Active, VehicleStatus.Retrieved };
            var vehicles    = SVD.Controller.Instance.VehicleController.GetVehiclesForPlace(p, status, 25, currentPage);
            var pagedList   = new PagedList <Vehicle>(vehicles, currentPage, 25, vehicles.TotalCount);

            // build a list of all parent-places, high to low-level.
            if (p.ParentPlace != null)
            {
                m.ParentPlaces = new List <Place>();
                var parent = p.ParentPlace;
                while (parent != null)
                {
                    var newPlace = parent;
                    m.ParentPlaces.Add(newPlace);
                    parent = parent.ParentPlace;
                }

                m.ParentPlaces.Reverse();
            }

            m.Place    = p;
            m.Vehicles = pagedList;
            return(View(m));
        }
Ejemplo n.º 27
0
 public List <PlaceModel> GetAllPlaces()
 {
     try
     {
         List <PlaceModel> placeList = new List <PlaceModel>();
         var placeData = this.placeRepository.GetAll();
         if (placeData != null)
         {
             foreach (var data in placeData)
             {
                 PlaceModel placeModel = new PlaceModel();
                 placeModel.Name             = data.Name;
                 placeModel.PlaceDescription = data.PlaceDescription;
                 placeModel.Address          = data.Address;
                 placeModel.ImageUrl         = data.ImageUrl;
                 placeModel.Tips             = data.Tips;
                 placeModel.Distance         = data.Distance;
                 placeModel.BestTimeToVisit  = data.BestTimeToVisit;
                 placeModel.Latitude         = data.Latitude;
                 placeModel.Longitude        = data.Longitude;
                 placeList.Add(placeModel);
             }
         }
         return(placeList);
     }
     catch (Exception ex)
     {
         throw new Exception("Error while get all place list due to:" + ex);
     }
 }
        public async Task <IActionResult> PutPlaceModel(int id, PlaceModel placeModel)
        {
            if (id != placeModel.PlaceId)
            {
                return(BadRequest());
            }

            _context.Entry(placeModel).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PlaceModelExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Ejemplo n.º 29
0
        public async Task <IActionResult> Post([FromBody] PlaceModel model)
        {
            var place = new Place()
            {
                Latitude      = model.Latitude.Value,
                Longitude     = model.Longitude.Value,
                Address       = model.Address,
                Phone         = model.Phone,
                Description   = model.Description,
                GuestsAllowed = model.GuestsAllowed.Value,
                Bathroom      = model.Bathroom,
                Food          = model.Food,
                Kitchen       = model.Kitchen,
                Parking       = model.Parking,
                Active        = true,
                Internet      = model.Internet,
                EntireHouse   = model.EntireHouse,
                UserId        = this.workContext.CurrentUserId,
                LocationId    = model.Location.Id
            };

            try
            {
                await this.placeService.InsertAsync(place);
            }
            catch (DoctorHouseException e)
            {
                return(this.BadRequest(e));
            }

            return(this.Created("GetPlaceById", place.Id));
        }
Ejemplo n.º 30
0
        public async Task <IActionResult> Post(PlaceModel placeModel)
        {
            var place        = _mapper.Map <Place>(placeModel);
            var createdPlace = await _placeService.AddAsync(place);

            return(Ok(createdPlace));
        }
        public static void AddPlace(PlaceModel place)
        {
            ValidatePlaceModel(place);

            var context = new FoursquareContext();
            Place newPlace = new Place();
            newPlace.Name = place.Name;
            newPlace.Latitude = place.Latitude;
            newPlace.Longitude = place.Longitude;
            context.Places.Add(newPlace);
            context.SaveChanges();
        }
        public static IEnumerable<PlaceModel> GetAll()
        {
            var context = new FoursquareContext();
            List<PlaceModel> models = new List<PlaceModel>();

            foreach (var place in context.Places)
            {
                PlaceModel currentModel = new PlaceModel();
                currentModel.Name = place.Name;
                currentModel.Latitude = place.Latitude;
                currentModel.Longitude = place.Longitude;
                models.Add(currentModel);
            }

            return models;
        }
 private static void ValidatePlaceModel(PlaceModel place)
 {
     if (place.Name == null || place.Name.Length < MinPlaceNameChars || place.Name.Length > MaxPlaceNameChars)
     {
         throw new ServerErrorException("Invalid Place Name", "INV_NICK_LEN");
     }
 }
        public static IEnumerable<PlaceModel> GetNearby(long userId)
        {
            var context = new FoursquareContext();
            var user = context.Users.FirstOrDefault(u => u.Id == userId);

            if (user == null)
            {
                throw new ServerErrorException("User does not exist", "ERR_GEN_SVR");
            }

            List<PlaceModel> models = new List<PlaceModel>();
            foreach (var place in context.Places)
            {
                if (IsInProximity(place.Latitude, place.Longitude, user.Latitude, user.Longitude))
                {

                    PlaceModel currentModel = new PlaceModel();
                    currentModel.Name = place.Name;
                    currentModel.Latitude = place.Latitude;
                    currentModel.Longitude = place.Longitude;
                    models.Add(currentModel);
                }
            }

            return models;
        }