I'm using dotConnect for MySQL, and Entity Developer to create a Linq to MySQL data model to use in an ASP.NET MVC project. The model is as below:
The bit I'm developing at the moment is the user registration process. I'm using the Repository pattern as recommended by people like Scott Guthrie and Steve Sanderson. I've managed to successfully create a user record with the following code:
Code: Select all
// 1. Encrypt password
user.Password = EncryptPassword(user.Password);
// 2. Generate GUID for verify code
user.VerificationGuid = System.Guid.NewGuid();
// 3. Set user level
user.UserType = userRepo.SetUserType(user.UserType.AccessLevelId);
// 4. Set sign up date
user.SignupDate = DateTime.Now;
// 5. Set some defaults for cross-compatibility with old code
user.SetDefaults();
// 6. Add to database
userRepo.Add(user);
userRepo.Save();
// 7. Send email to user
user.SendVerificationEmail();
Code: Select all
User user = userRepo.GetUserForActivation(verify, email);
if (user == null)
return View("ActivationError");
// Update user's active status
user.Active = true;
// Persist
userRepo.Save();
Any help that can be provided would be extremely welcome - I'm close to tearing my hair out here!
Thanks
Jon[/img]