public async Task <bool> SaveChangesAsync(StaticSiteInfo info) { try { _context.Update(info); await _context.SaveChangesAsync(); return(true); } catch (Exception) { return(false); } }
public async Task <IActionResult> OnPostAsync() { var user = await _userManager.GetUserAsync(User); if (user == null) { return(NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'.")); } if (!ModelState.IsValid) { await LoadAsync(user); return(Page()); } if (Input.FormFile == null) { return(RedirectToPage()); } var imageId = await _cloudinaryService.UploadImageAsync(Input.FormFile); if (string.IsNullOrWhiteSpace(imageId)) { return(RedirectToPage()); } // Deleting old profile image if any if (!string.IsNullOrWhiteSpace(user.ImageId)) { await _cloudinaryService.DeleteImageAsync(user.ImageId); } // Setting the new profile image user.ImageId = imageId; _dbContext.Update(user); await _dbContext.SaveChangesAsync(); await _signInManager.RefreshSignInAsync(user); StatusMessage = "Your profile has been updated"; return(RedirectToPage()); }
public async Task <bool> SaveChangesAsync(ComponentTypeDetail detail) { try { if (detail.Id == 0) { await _context.AddAsync(detail); } else { _context.Update(detail); } await _context.SaveChangesAsync(); return(true); } catch (Exception) { return(false); } }
public async Task <bool> SaveChangesAsync(UnitMultiplier multiplier) { try { if (multiplier.Id == 0) { await _context.AddAsync(multiplier); } else { _context.Update(multiplier); } await _context.SaveChangesAsync(); return(true); } catch (Exception) { return(false); } }