Beispiel #1
0
        public async Task <IHttpActionResult <NounDto> > Post([FromBody] NounDto nounDto)
        {
            try
            {
                Noun noun = new Noun
                {
                    Value            = nounDto.Value,
                    ModificationDate = DateTime.Now
                };
                if (await _nounService.ExistsAsync(noun))
                {
                    return(BadRequest <NounDto>("Entry already exists"));
                }
                else
                {
                    noun = await _nounService.CreateAsync(noun);

                    return(Ok(noun.ToNounDto()));
                }
            }
            catch
            {
                return(InternalServerError <NounDto>(new NounDto()));
            }
        }