internal bool hasRelationship(DTOHouseFavorite fav) { string sql = "SELECT * FROM housefavorites WHERE houseId = @HouseId AND user = @User"; var found = _db.QueryFirstOrDefault <DTOHouseFavorite>(sql, fav); return(found != null); }
internal DTOHouseFavorite Create(DTOHouseFavorite fav) { if (_repo.hasRelationship(fav)) { throw new Exception("you already have that fav"); } return(_repo.Create(fav)); }
public ActionResult <DTOHouseFavorite> Create([FromBody] DTOHouseFavorite fav) { try { fav.User = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value; return(Ok(_hfs.Create(fav))); } catch (System.Exception err) { return(BadRequest(err.Message)); } }
internal DTOHouseFavorite Create(DTOHouseFavorite fav) { string sql = @" INSERT INTO housefavorites (user, carid) VALUES (@User, @CarId); SELECT LAST_INSERT_ID();"; fav.Id = _db.ExecuteScalar <int>(sql, fav); return(fav); }
internal object Create(DTOHouseFavorite fav) { throw new NotImplementedException(); }