Exemplo n.º 1
0
        public Guid GetUserId(string apiKey)
        {
            if (string.IsNullOrWhiteSpace(apiKey))
            {
                throw new ArgumentNullException("apiKey");
            }
            LocanDal dal  = new LocanDal();
            User     user = dal.GetUniqueUser(u => string.Compare(apiKey, u.ApiKey, StringComparison.OrdinalIgnoreCase) == 0, true);

            return(user.Id);
        }
Exemplo n.º 2
0
        public Guid RegisterUser(string apiKey)
        {
            if (string.IsNullOrWhiteSpace(apiKey))
            {
                throw new ArgumentNullException("apiKey");
            }

            User newUser = new User {
                ApiKey = apiKey
            };

            // see if the user exists if so get that ID if not create a new one
            LocanDal dal = new LocanDal();

            User existingUser = dal.GetUniqueUser(user => user.ApiKey == apiKey, false);

            if (existingUser == null)
            {
                existingUser = dal.AddUser(newUser);
            }

            return(existingUser.Id);
        }