public JsonResult AddPersonToParty([FromBody] GuestlistModel guestlist) { var result = _partyservice.AddPersonToParty(guestlist); if (!result) { return(new JsonResult("Person could not be added To Party")); } return(new JsonResult("Person Added To Party")); }
public bool AddPersonToParty(GuestlistModel guestlist) { string sqlDataSource = _configuration.GetConnectionString("PartyAppCon"); using (SqlConnection myCon = new SqlConnection(sqlDataSource)) { myCon.Open(); using (SqlCommand myCommand = new SqlCommand(StoredProcedures.ADD_PERSON_TO_PARTY, myCon)) { myCommand.CommandType = CommandType.StoredProcedure; myCommand.Parameters.Add(Parameters.PARTY_ID, SqlDbType.Int).Value = guestlist.PartyId; myCommand.Parameters.Add(Parameters.PERSON_ID, SqlDbType.Int).Value = guestlist.PersonId; myCommand.Parameters.Add(Parameters.DRINK_ID, SqlDbType.Int).Value = guestlist.DrinkId; myCommand.ExecuteNonQuery(); myCon.Close(); } return(true); } }