public async Task <bool> Update(User user) { if (user == null) { throw new ArgumentNullException(nameof(user)); } var exsistedUser = await _context.Users .FirstOrDefaultAsync(f => f.Id == user.Id); if (exsistedUser == null) { throw new ArgumentNullException(nameof(exsistedUser)); } _context.Entry(exsistedUser).State = EntityState.Modified; exsistedUser.Name = user.Name; exsistedUser.SecondName = user.SecondName; exsistedUser.PhoneNumber = user.PhoneNumber; exsistedUser.Email = user.Email; exsistedUser.NormalizedEmail = user.Email.ToUpper(); exsistedUser.PasswordHash = user.PasswordHash; exsistedUser.UserName = user.Name; await _context.SaveChangesAsync(); return(true); }
public async Task <bool> Update(ProductCard productCard) { if (productCard == null) { throw new ArgumentNullException(nameof(productCard)); } var existedProductCard = await _context.ProductCards .FirstOrDefaultAsync(f => f.Id == productCard.Id); if (existedProductCard == null) { throw new ArgumentNullException(nameof(existedProductCard)); } _context.Entry(existedProductCard).State = EntityState.Modified; existedProductCard.DateCreated = productCard.DateCreated; existedProductCard.Quantity = productCard.Quantity; await _context.SaveChangesAsync(); return(true); }