Ejemplo n.º 1
0
        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"));
        }
Ejemplo n.º 2
0
        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);
            }
        }