Beispiel #1
0
        public IHttpActionResult Post([FromBody] ContactPostModel value)
        {
            //Checking if ModelState is invalid and throw exception
            if (!ModelState.IsValid)
            {
                //If ModelState fails validation, returns validation error response
                return(BadRequest(ModelState));
            }
            var entity = this._contactRepository.Post(value.ToEntity());

            //If ModelState validation is successed, returns as a response the Action API name, Contact Id and the model
            return(CreatedAtRoute("DefaultApi", new { id = entity.ContactId }, new ContactModel(entity)));
        }
Beispiel #2
0
        // POST: api/Contact
        public ContactModel Post([FromBody] ContactPostModel value)
        {
            var entity = this._contactRepository.Post(value.ToEntity());

            return(new ContactModel(entity));
        }