Example #1
0
        public static UserRegisterResponse Register(UserRegisterRequest model)
        {
            var user = MongoUser.Collection.GetOne(QueryField.FromExpression<MongoUser.User>(a => a.Email, model.Email));

            if (user != null)
            {
                throw new RequestValidationException("Email Address In Use");
            }

            user = new MongoUser.User();
            user.Email = model.Email;
            user.Password = model.Password;
            user.Insert();

            return new UserRegisterResponse()
            {
                UserId=user.Id.ToString()
            };
        }
Example #2
0
        public static UserRegisterResponse Register(UserRegisterRequest model)
        {
            var user = MongoUser.Collection.GetOne(QueryField.FromExpression <MongoUser.User>(a => a.Email, model.Email));

            if (user != null)
            {
                throw new RequestValidationException("Email Address In Use");
            }

            user          = new MongoUser.User();
            user.Email    = model.Email;
            user.Password = model.Password;
            user.Insert();

            return(new UserRegisterResponse()
            {
                UserId = user.Id.ToString()
            });
        }
Example #3
0
        public static async Task <UserRegisterResponse> Register(UserRegisterRequest model)
        {
            var user = await MongoUser.Collection.GetOne(a => a.Email == model.Email);

            if (user != null)
            {
                throw new RequestValidationException("Email Address In Use");
            }

            user          = new MongoUser.User();
            user.Email    = model.Email;
            user.Password = model.Password;
            await user.Insert();

            return(new UserRegisterResponse()
            {
                UserId = user.Id.ToString()
            });
        }