/// <summary> /// Deletes grammar with id. /// </summary> /// <param name="grammarId">Id of grammar that should be deleted.</param> /// <returns> /// When rejected, an <see cref="Exception" /> with info about error that occured. /// </returns> public static IPromise DeleteGrammar(string grammarId) { if (!GrammarList.ContainsKey(grammarId)) { return(Promise.Rejected(new ApplicationException("Delete grammar request error:\nRequested grammar not found."))); } return(WebAPI.DeleteGrammar(grammarId) .Then(() => { grammarList.Remove(grammarId); SaveGrammarList(); })); }