public async Task Delete(string userId) { Context.Entities.Picture entity = await _context.Pictures.FirstOrDefaultAsync(x => x.Id == userId); if (entity != null) { _context.Pictures.Remove(entity); await _context.SaveChangesAsync(); } }
public async Task CreateOrUpdate(Picture picture) { Context.Entities.Picture entity = await _context.Pictures.FirstOrDefaultAsync(x => x.Id == picture.Id); if (entity != null) { entity = _mapper.Map <Context.Entities.Picture>(picture); _context.Entry(entity).State = EntityState.Modified; } else { await _context.Pictures.AddAsync(_mapper.Map <Context.Entities.Picture>(picture)); } await _context.SaveChangesAsync(); }