public async Task UnblockUser(string forUserName, string unblockUserName) { Guid blockingUserId = await _dbContext.TegetgramUsers.Where(u => u.Owner.UserName == forUserName) .Select(u => u.Id) .SingleOrDefaultAsync(); Guid unblockedUserId = await _dbContext.TegetgramUsers.Where(u => u.Owner.UserName == unblockUserName) .Select(u => u.Id) .SingleOrDefaultAsync(); if (unblockedUserId == null) { throw new ApplicationException($"User {unblockUserName} could not be found."); } if (blockingUserId == null) { throw new ApplicationException($"User {forUserName} could not be found."); } if (_dbContext.UserBlockings.Any(b => b.BlockerId == blockingUserId && b.BlockedId == unblockedUserId)) { UserBlocking blocking = new UserBlocking { BlockerId = blockingUserId, BlockedId = unblockedUserId }; _dbContext.Remove <UserBlocking>(blocking); await _dbContext.SaveChangesAsync(); } }
public int Save(UserBlocking _object) { int _returnValue = base.Save <UserBlocking>("spAddEditUserBlocking", _object); return(_returnValue); }