using Yuna.Website.Server.Model;

namespace Yuna.Website.Server.Storage.Repositories.UserBindings
{
    public class UserBindingRepository : IUserBindingsRepository
    {
        private static List<UserBinding> _inMemoryContext = new();

        public UserBindingRepository() { }

        public UserBinding Create(UserBinding userBinding)
        {
            userBinding.Id = _inMemoryContext.Count;
            _inMemoryContext.Add(userBinding);
            return userBinding;
        }

        public UserBinding? GetUserBinding(string code)
        {
            var binding = _inMemoryContext.FirstOrDefault(x => x.Code.Equals(code));
            return binding;
        }
    }
}
