Exemple #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));
        }