/// <summary> /// Edits Single NewsItem in Database from <see cref="EditNewsItemViewModel"/> /// </summary> /// <param name="model"></param> /// <returns><see cref="bool"/></returns> public async Task <bool> EditSingleNews(EditNewsItemViewModel model) { if (await _healthyGamerPortalDbContext.NewsItem.AsNoTracking().FirstOrDefaultAsync(i => i.Id == model.Id) != null) { var newsItem = _mapper.Map <EditNewsItemViewModel, NewsItem>(model); _healthyGamerPortalDbContext.Update(newsItem); 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); }
/// <summary> /// Edits a Single <see cref="ApplicationUser"/> in Database from <see cref="EditApplicationUserViewModel"/> /// </summary> /// <param name="model"></param> /// <returns><see cref="bool"/></returns> public async Task <bool> EditSingleApplicationUser(EditApplicationUserViewModel model) { var existingApplicationUser = await _healthyGamerPortalDbContext.ApplicationUsers.AsNoTracking().FirstOrDefaultAsync(i => i.Id == model.Id); if (existingApplicationUser != null) { ApplicationUser applicationUser = _mapper.Map <ApplicationUser>(model); applicationUser.Password = existingApplicationUser.Password; _healthyGamerPortalDbContext.Update(applicationUser); await _healthyGamerPortalDbContext.SaveChangesAsync(); return(true); } return(false); }