/// <summary>
        /// Deletes Single <see cref="ApplicationUser"/> From Database by <see cref="DeleteApplicationUserViewModel"/>
        /// </summary>
        /// <param name="model"></param>
        /// <returns><see cref="bool"/></returns>
        public async Task <bool> DeleteSingleApplicationUser(DeleteApplicationUserViewModel model)
        {
            if (_healthyGamerPortalDbContext.ApplicationUsers.AsNoTracking().First(i => i.Id == model.Id) != null)
            {
                ApplicationUser DeleteApplicationUser = _mapper.Map <ApplicationUser>(model);
                _healthyGamerPortalDbContext.Remove(DeleteApplicationUser);
                await _healthyGamerPortalDbContext.SaveChangesAsync();

                return(true);
            }
            return(false);
        }
Пример #2
0
        /// <summary>
        /// Deletes Single NewsItem From Database by <see cref="DeleteNewsItemViewModel"/>
        /// </summary>
        /// <param name="model"></param>
        /// <returns><see cref="bool"/></returns>
        public async Task <bool> DeleteSingleNews(DeleteNewsItemViewModel model)
        {
            var existingNewsItem = await _healthyGamerPortalDbContext.NewsItem.AsNoTracking().FirstOrDefaultAsync(i => i.Id == model.Id);

            if (existingNewsItem != null)
            {
                _healthyGamerPortalDbContext.Remove(existingNewsItem);
                await _healthyGamerPortalDbContext.SaveChangesAsync();

                return(true);
            }
            return(false);
        }