private async Task <IHttpActionResult> Post(Status status) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { await _repository.AddAsync(status); } catch (DbUpdateException) { if (await StatusExistsAsync(status.Id)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = status.Id }, status)); }
public async Task <int> AddAsync(Models.Status status) { if (status != null) { return(await _repository.AddAsync(status)); } return(0); }