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);
        }
Exemplo n.º 2
0
 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);
        }
Exemplo n.º 5
0
 internal object Create(DTOHouseFavorite fav)
 {
     throw new NotImplementedException();
 }