Ejemplo n.º 1
0
        public async Task<IEnumerable<int>> DeleteMultipleNoteTypes( NoteType[] values, string name ) {
            if ( !await noteTypesDAL.ValidateNoteTypesInSubs( values ) ) {
                throw new HttpResponseException( new System.Net.Http.HttpResponseMessage( System.Net.HttpStatusCode.BadRequest ) { ReasonPhrase = "You gone and changed a NoteType to a different Subreddit ya goof!" } );
            }
            foreach ( NoteType nt in values ) {

                if ( !ClaimsPrincipal.Current.HasClaim( $"urn:snoonotes:subreddits:{nt.SubName.ToLower()}:admin", "true" ) )
                    throw new UnauthorizedAccessException( "You are not an admin of this subreddit!" );

            }
            await noteTypesDAL.DeleteMultipleNoteTypes( values, name );
            Signalr.SnooNoteUpdates.Instance.RefreshNoteTypes( values.Select( nt => nt.SubName ).Distinct() );
            return values.Select( nt => nt.NoteTypeID );
        }
Ejemplo n.º 2
0
        public async Task<IEnumerable<Models.NoteType>> UpdateMultipleNoteTypes( NoteType[] values, string name ) {
            foreach ( Models.NoteType nt in values ) {
                if ( !await ValidateNoteType( nt ) ) {
                    throw new HttpResponseException( System.Net.HttpStatusCode.BadRequest );
                }

            }
            await noteTypesDAL.UpdateMultipleNoteTypes( values, name );
            Signalr.SnooNoteUpdates.Instance.RefreshNoteTypes( values.Select( nt => nt.SubName ).Distinct() );
            return values;
        }