internal string Delete(PeopleHobby cs)
        {
            PeopleHobby exists = _phr.Find(cs);

            if (exists == null)
            {
                throw new Exception("Invalid Id Combination");
            }
            _phr.Delete(exists.Id);
            return("Successfully Deleted");
        }
        internal string Create(PeopleHobby newData)
        {
            PeopleHobby exists = _phr.Find(newData);

            if (exists != null)
            {
                throw new Exception("Student already enrolled");
            }
            _phr.Create(newData);
            return("Successfully Joined");
        }
 public ActionResult <String> Edit([FromBody] PeopleHobby cs)
 {
     try
     {
         return(Ok(_phs.Delete(cs)));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
 public ActionResult <String> Create([FromBody] PeopleHobby newData)
 {
     try
     {
         return(Ok(_phs.Create(newData)));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
        internal void Create(PeopleHobby newData)
        {
            string sql = @"
            INSERT INTO peoplehobbys 
            (personId, hobbyId) 
            VALUES 
            (@personId, @hobbyId);
            SELECT LAST_INSERT_ID();
            ";
            int    id  = _db.ExecuteScalar <int>(sql, newData);

            newData.Id = id;
            return;
        }
        internal PeopleHobby Find(PeopleHobby ph)
        {
            string sql = "SELECT * FROM peoplehobbys WHERE (personId = @personId AND hobbyId = @hobbyId)";

            return(_db.QueryFirstOrDefault(sql, ph));
        }