コード例 #1
0
        /// <summary>
        /// Attempts to delete a spell with a given id.
        ///
        /// ROUTE
        /// `api/spell/{id}`
        ///
        /// RESPONSE BODY
        /// {
        ///     "success": `bool`,
        ///     "spell": {
        ///         "id": `int`,
        ///         "name": `string`,
        ///         "level": `int`,
        ///         "school": `string`,
        ///         "castingTime": `string`,
        ///         "range": `string`,
        ///         "verbal": `bool`,
        ///         "somatic": `bool`,
        ///         "materials": `string`,
        ///         "duration": `string`,
        ///         "ritual": `bool`,
        ///         "description": `string`
        ///     }
        /// }
        /// </summary>
        /// <param name="id">The ID of the spell.</param>
        /// <returns>The response body.</returns>
        public async Task <SpellDeleteResponse> Delete(int id)
        {
            // Query to get spell information. Maybe this isn't
            // needed and we can just return a status code.
            var spell = await _spellRepo.GetAsync(id);

            var response = new SpellDeleteResponse()
            {
                Success = false
            };

            if (await _spellRepo.DeleteAsync(id))
            {
                response.Success = true;
                response.Spell   = spell.GetInfo();
            }
            return(response);
        }