public async Task <IActionResult> PutDonation(int id, Donation donation) { if (id != donation.Id) { return(BadRequest()); } _context.Entry(donation).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DonationExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task ConsumeAsync(CharityActionCreatedEvent message) { var charity = await _context.Charities.FirstOrDefaultAsync(c => c.CharityKey == message.CharityKey); charity?.ChartityActions.Add(_mapper.Map <CharityAction>(message)); await _context.SaveChangesAsync(); }
public async Task ConsumeAsync(UserUpdatedEvent message) { var userToUpdate = await _context.Users.SingleOrDefaultAsync(u => u.UserKey == message.UserKey); if (userToUpdate != null) { userToUpdate.UserName = Helpers.GetUserName(message); userToUpdate.ProfileImage = message.ProfileImage; await _context.SaveChangesAsync(); } }
public async Task ConsumeAsync(CharityActionUpdatedEvent message) { var charityActionToUpdate = await _context.CharityActions .FirstOrDefaultAsync(c => c.CharityActionKey == message.CharityActionKey); if (charityActionToUpdate != null) { _context.Entry(charityActionToUpdate).CurrentValues.SetValues(message); await _context.SaveChangesAsync(); } }
public async Task ConsumeAsync(UserCreatedEvent message) { _context.Users.Add(_mapper.Map <User>(message)); await _context.SaveChangesAsync(); }
public async Task ConsumeAsync(CharityCreatedEvent message) { _context.Add(_mapper.Map <Charity>(message)); await _context.SaveChangesAsync(); }