public HttpResponseMessage Post(Tag item)
{
if (ModelState.IsValid)
{
this.tagRepository.InsertOrUpdate(item);
this.tagRepository.Save();
HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, item);
response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = item.Id }));
return response;
}
else
{
var validationResults = this.ModelState.SelectMany(m => m.Value.Errors.Select(x => x.ErrorMessage + "(Property: " + m.Key + ")" ));
throw new HttpResponseException(this.Request.CreateResponse(HttpStatusCode.BadRequest, validationResults));
}
}