예제 #1
0
        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));
        }
예제 #2
0
        public async Task <int> AddAsync(Models.Status status)
        {
            if (status != null)
            {
                return(await _repository.AddAsync(status));
            }

            return(0);
        }