public IActionResult GetById(int id) { if (id == 0) { return(NotFound()); } var house = _houseRepo.GetHouseById(id); if (house == null) { return(BadRequest()); } return(Ok(house)); }
public IActionResult Post([FromBody] Like like) { if (like == null) { return(BadRequest()); } var userId = User.FindFirstValue(ClaimTypes.NameIdentifier); if (userId == null) { return(Unauthorized()); } var house = _houseRepo.GetHouseById(like.HouseId); if (house == null) { return(NotFound()); } like.UserId = Guid.Parse(userId); var savedLike = _likesRepo.AddLike(like, Guid.Parse(userId)); return(CreatedAtAction(nameof(GetById), new { Id = savedLike.Id }, savedLike)); }