Example #1
0
        public async Task <IActionResult> Update(string id,
                                                 [FromBodyAttribute] ResponseData.TopicIgnoreUniqId topic)
        {
            if (topic == null || string.IsNullOrEmpty(id) ||
                string.IsNullOrEmpty(topic.Description) ||
                string.IsNullOrEmpty(topic.Notes))
            {
                return(BadRequest());
            }

            try
            {
                var response = await _quizManager.UpdateTopic(id, topic);

                if (response != null)
                {
                    return(new StatusCodeResult((int)HttpStatusCode.NoContent));
                }
            }
            catch (Exception ex)
            {
                _loggerTopic.LogCritical($"Error in topic Update : {ex}");
            }

            return(new StatusCodeResult((int)HttpStatusCode.NotModified));
        }
Example #2
0
        public async Task <IActionResult> AddTopic([FromBodyAttribute] ResponseData.TopicIgnoreUniqId topic)
        {
            try
            {
                await _quizManager.AddTopicAsync(topic);
            }
            catch (Exception ex)
            {
                _loggerTopic.LogCritical($"AddTopic{ex}");
                return(BadRequest());
            }

            // Response.Headers.Add("Location", ""); // TODO send new objectid
            return(new StatusCodeResult((int)HttpStatusCode.Created));
        }