public CommentFlatModel(Comment comment)
 {
     this.Content = comment.Content;
     this.CreationDate = comment.PostTime;
     this.Place = comment.Place.Name;
     this.User = comment.User.Username;
 }
 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 CreateComment(string sessionKey, [FromBody]CommentRegisterModel inputComment)
        {
            User currentUser = usersRepo.All().Where(u => u.SessionKey == sessionKey).FirstOrDefault();

            Place currentPlace = placesRepo.All().Where(p => p.Id == inputComment.PlaceId).FirstOrDefault();

            if (currentUser == null)
            {
                return this.Request.CreateErrorResponse(HttpStatusCode.NotFound, "User - Session Key mismatch.");
            }
            else if (currentPlace == null)
            {
                return this.Request.CreateErrorResponse(HttpStatusCode.NotFound, "Place wasn't found.");
            }

            Comment newComment = new Comment()
            {
                Content = inputComment.Content,
                Place = currentPlace,
                PlaceId = currentPlace.Id,
                User = currentUser,
                UserId = currentUser.Id,
                PostTime = DateTime.Now,
            };

            try
            {
                commentsRepo.Add(newComment);
            }
            catch(Exception ex)
            {
                return this.Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.InnerException.ToString());
            }

            return this.Request.CreateResponse(HttpStatusCode.OK);
        }