public CommentModel(Comment comment) { this.Id = comment.Id; this.Content = comment.Content; this.PostTime = comment.PostTime; this.UserId = comment.UserId; this.PlaceId = comment.PlaceId; this.User = new UserModel(comment.User); this.Place = new PlaceModel(comment.Place); }
public HttpResponseMessage GetAllPlaces() { ICollection<PlaceModel> resultPlaces = new List<PlaceModel>(); var allPlaces = placesRepo.All(); foreach (Place currentPlace in allPlaces) { PlaceModel currentModelPlace = new PlaceModel(currentPlace); resultPlaces.Add(currentModelPlace); } if (resultPlaces.Count == 0) { return this.Request.CreateErrorResponse(HttpStatusCode.NoContent, "There aren't any places yet"); } else { return this.Request.CreateResponse(HttpStatusCode.OK, resultPlaces); } }
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); }
public HttpResponseMessage GetCurrentUserPlaces(string sessionKey) { 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> resultPlaces = new List<PlaceModel>(); foreach (Place currentPlace in currentUser.Places) { PlaceModel currentPlaceModel = new PlaceModel(currentPlace); resultPlaces.Add(currentPlaceModel); } return this.Request.CreateResponse(HttpStatusCode.OK, resultPlaces); }
public UserPlaceModel(UserModel user, PlaceModel place) { this.User = user; this.Place = place; }