public async Task <bool> DeleteFriend(FriendBaseRequestModel model)
        {
            var user = await _context.PlayerIdentity.FirstOrDefaultAsync(t => t.Id == model.PlayerId);

            if (user == null)
            {
                return(false);
            }

            var friendEntity = await _context.Friends.FirstOrDefaultAsync(t =>
                                                                          t.FriendId == model.FriendId && t.OwnerPlayerId == model.PlayerId);

            if (friendEntity == null)
            {
                return(false);
            }

            var deleteResult = _context.Friends.Remove(friendEntity);

            if (deleteResult.State == EntityState.Deleted)
            {
                await _context.SaveChangesAsync();

                return(true);
            }

            return(false);
        }
        public async Task <bool> AddNewFriend(FriendBaseRequestModel model)
        {
            if (model.FriendId == model.PlayerId)
            {
                return(false);
            }

            var user = await _context.PlayerIdentity.FirstOrDefaultAsync(t => t.Id == model.PlayerId);

            if (user == null)
            {
                return(false);
            }

            if (await _context.Friends.AnyAsync(t => t.Id == model.PlayerId && t.FriendId == model.FriendId))
            {
                return(false);
            }

            var friendEntity = new Friends()
            {
                FriendId = model.FriendId, OwnerPlayerId = model.PlayerId
            };

            var addResult = await _context.Friends.AddAsync(friendEntity);

            if (addResult.State == EntityState.Added)
            {
                await _context.SaveChangesAsync();

                return(true);
            }

            return(false);
        }
 public async Task <bool> DeleteFriend(FriendBaseRequestModel data)
 {
     return(await _friendService.DeleteFriend(data));
 }
 public async Task <bool> AddNewFriend(FriendBaseRequestModel data)
 {
     return(await _friendService.AddNewFriend(data));
 }