コード例 #1
0
        /// <summary>
        /// Add TEntity async.
        /// </summary>
        /// <param name="entity">Entity to add.</param>
        /// <returns>Added TEntity.</returns>
        public async Task <TEntity> AddAsync(TEntity entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException($"{nameof(AddAsync)} entity must not be null");
            }

            try
            {
                await PlannerDbContext.AddAsync(entity);

                await PlannerDbContext.SaveChangesAsync();

                return(entity);
            }
            catch (Exception ex)
            {
                throw new Exception($"{nameof(entity)} could not be saved: {ex.Message}");
            }
        }
コード例 #2
0
ファイル: UnitOfWork.cs プロジェクト: thanuja89/Planner
 public Task CompleteAsync()
 {
     return(_context.SaveChangesAsync());
 }