public async Task <UserPushSubscription> Update(UserPushSubscription subscription) { _context.UserPushSubscriptions.Update(subscription); await _context.SaveChangesAsync(); return(subscription); }
public async Task <UserPushSubscription> Create(int userId, string endpoint, string p256dh, string auth) { var userPushSubscription = new UserPushSubscription { UserId = userId, EndPoint = endpoint, P256Dh = p256dh, Auth = auth }; var exists = await _repository.Find(userId); if (exists == null) { await _repository.Create(userPushSubscription); return(userPushSubscription); } exists.EndPoint = userPushSubscription.EndPoint; exists.P256Dh = userPushSubscription.P256Dh; exists.Auth = userPushSubscription.Auth; exists.UserId = userPushSubscription.UserId; return(await _repository.Update(exists)); }
public async Task <UserPushSubscription> Create(UserPushSubscription subscription) { await _context.UserPushSubscriptions.AddAsync(subscription); await _context.SaveChangesAsync(); return(null); }