예제 #1
0
 protected static async Task SaveChanges(SocialGamificationAssetContext _context, bool isAsync = false)
 {
     try
     {
         if (isAsync)
         {
             await _context.SaveChangesAsync();
         }
         else
         {
             _context.SaveChanges();
         }
     }
     catch (DbUpdateException e)
     {
         throw e;
     }
 }
예제 #2
0
        /// <summary>
        ///     Asynchronously save data
        /// </summary>
        /// <returns>
        ///     <para>
        ///         ErrorContentResult if
        ///         <see cref="System.Data.Entity.Infrastructure.DbUpdateException" />
        ///     </para>
        ///     <para>exception occurs</para>
        /// </returns>
        public static async Task <ContentResult> SaveChanges(
            SocialGamificationAssetContext _context,
            bool isAsync = false)
        {
            try
            {
                if (isAsync)
                {
                    await _context.SaveChangesAsync();
                }
                else
                {
                    _context.SaveChanges();
                }
            }
            catch (DbUpdateException e)
            {
                return(HttpResponseHelper.ErrorContentResult(
                           GetExceptionString(e),
                           StatusCodes.Status500InternalServerError));
            }

            return(null);
        }
예제 #3
0
        /// <summary>
        ///     Asynchronously save data
        /// </summary>
        /// <returns>
        ///     <para>
        ///         ErrorContentResult if
        ///         <see cref="System.Data.Entity.Infrastructure.DbUpdateException" />
        ///     </para>
        ///     <para>exception occurs</para>
        /// </returns>
        public static async Task<ContentResult> SaveChanges(
            SocialGamificationAssetContext _context,
            bool isAsync = false)
        {
            try
            {
                if (isAsync)
                {
                    await _context.SaveChangesAsync();
                }
                else
                {
                    _context.SaveChanges();
                }
            }
            catch (DbUpdateException e)
            {
                return HttpResponseHelper.ErrorContentResult(
                    GetExceptionString(e),
                    StatusCodes.Status500InternalServerError);
            }

            return null;
        }
예제 #4
0
 protected static async Task SaveChanges(SocialGamificationAssetContext _context, bool isAsync = false)
 {
     try
     {
         if (isAsync)
         {
             await _context.SaveChangesAsync();
         }
         else
         {
             _context.SaveChanges();
         }
     }
     catch (DbUpdateException e)
     {
         throw e;
     }
 }