/// <summary> /// </summary> public IBaseProps Create(IBaseProps p) { int rowsAffected = 0; EventProps props = (EventProps)p; DBCommand command = new DBCommand(); command.CommandText = "usp_EventCreate"; command.CommandType = CommandType.StoredProcedure; command.Parameters.Add("@EventID", SqlDbType.Int); command.Parameters.Add("@UserID", SqlDbType.Int); command.Parameters.Add("@EventTitle", SqlDbType.NVarChar); command.Parameters.Add("@EventDescription", SqlDbType.NVarChar); command.Parameters.Add("@EventDate", SqlDbType.Date); command.Parameters[0].Direction = ParameterDirection.Output; command.Parameters["@UserID"].Value = props.userID; command.Parameters["@EventTitle"].Value = props.title; command.Parameters["@EventDescription"].Value = props.description; command.Parameters["@EventDate"].Value = props.date; try { rowsAffected = RunNonQueryProcedure(command); if (rowsAffected == 1) { props.ID = (int)command.Parameters[0].Value; props.ConcurrencyID = 1; return(props); } else { throw new Exception("Unable to insert record. " + props.ToString()); } } catch (Exception e) { // log this error throw; } finally { if (mConnection.State == ConnectionState.Open) { mConnection.Close(); } } }