public async Task <IHttpActionResult> Post(SupplierModel model) { try { if (ModelState.IsValid && model != null) { var supplier = _mapper.Map <Supplier>(model); _repository.AddSupplier(supplier); if (await _repository.SaveChangesAsync()) { var newModel = _mapper.Map <SupplierModel>(supplier); return(CreatedAtRoute("", "", newModel)); } else { return(Content(HttpStatusCode.Conflict, string.Format("Supplier with id {0} could not be updated", supplier.SupplierID))); } } else { return(Content(HttpStatusCode.BadRequest, "Incorrect input data")); } } catch { return(InternalServerError()); } }