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() }; }
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() }); }
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() }); }