public async Task <bool> AddAsync(T entity) { if (entity == null) { throw new ArgumentNullException("entity"); } await entities.AddAsync(entity); bool succeeded = await context.SaveChangesAsync() > 0; if (!succeeded) { throw new RestException(HttpStatusCode.BadRequest, new { Save = $"Problem adding {nameof(T)}." }); } return(succeeded); }
public async Task <bool> SaveAsync(Trail trail) { context.Trails.Add(trail); return(await context.SaveChangesAsync() > 0); }