/// <summary> /// Creates Single NewsItem in Database from <see cref="CreateNewsItemViewModel"/> /// </summary> /// <param name="model"></param> /// <returns>see cref="bool"/></returns> public async Task <bool> CreateSingleNews(CreateNewsItemViewModel model) { var newsItem = _mapper.Map <CreateNewsItemViewModel, NewsItem>(model); _healthyGamerPortalDbContext.NewsItem.Add(newsItem); await _healthyGamerPortalDbContext.SaveChangesAsync(); return(true); }
/// <summary> /// Creates a Single <see cref="ApplicationUser"/> in the Database from <see cref="CreateApplicationUserViewModel"/> /// </summary> /// <param name="model"></param> /// <returns><see cref="bool"/></returns> public async Task <bool> CreateSingleApplicationUser(CreateApplicationUserViewModel model) { if (!_healthyGamerPortalDbContext.ApplicationUsers.Any(i => i.Email == model.Email)) { ApplicationUser applicationUser = _mapper.Map <ApplicationUser>(model); CreatePasswordHash(Encoding.UTF8.GetBytes("NotDiscord"), out string salt, out string hashedPassword); applicationUser.Password = hashedPassword; applicationUser.Salt = salt; _healthyGamerPortalDbContext.ApplicationUsers.Add(applicationUser); await _healthyGamerPortalDbContext.SaveChangesAsync(); return(true); } return(false); }
/// <summary> /// Edits a Single LocalizationRecords <see cref="LocalizationRecordViewModel"/> /// </summary> /// <param name="model"></param> /// <returns><see cref="bool"/></returns> public async Task <bool> EditSingleLocalizationRecord(LocalizationRecordViewModel model) { var existingLocalizationRecords = await _healthyGamerPortalDbContext.LocalizationRecord.AsNoTracking().FirstOrDefaultAsync(i => i.Id == model.Id); if (existingLocalizationRecords != null) { existingLocalizationRecords.Text = model.Text; _healthyGamerPortalDbContext.Update(existingLocalizationRecords); await _healthyGamerPortalDbContext.SaveChangesAsync(); return(true); } return(false); }