Example #1
0
        public IHttpActionResult Post([FromBody] Topic topic)
        {
            try
            {
                if (topic == null)
                {
                    return(BadRequest());
                }



                var result = _repository.Insert(topic);
                if (result.Status == RepositoryActionStatus.Created)
                {
                    // map to dto
                    return(Created <Topic>(Request.RequestUri
                                           + "/" + topic.Id.ToString(), topic));
                }

                return(BadRequest());
            }
            catch (Exception)
            {
                return(InternalServerError());
            }
        }