예제 #1
0
 public ActionResult Register(User RegisterUser)
 {
     if (ModelState.IsValid)
     {
         MembershipCreateStatus createStatus = repo.CreateUser(RegisterUser.UserName, RegisterUser.Password, RegisterUser.Email);
         if (createStatus == MembershipCreateStatus.Success)
         {
             FormsAuthenticationService.SignIn(RegisterUser.UserName);
             return RedirectToAction("Index", "Home");
         }
         else
         {
             ModelState.AddModelError("", AccountValidation.ErrorCodeToString(createStatus));
         }
     }
     return View(RegisterUser);
 }
예제 #2
0
 /// <summary>
 /// Create User
 /// </summary>
 /// <param name="UserName">User Name</param>
 /// <param name="Password">Password</param>
 /// <param name="Email">Email</param>
 /// <returns>Registration result</returns>
 public MembershipCreateStatus CreateUser(string UserName, string Password, string Email)
 {
     if (modelContainer.Users.Any(u => u.UserName == UserName))
         return MembershipCreateStatus.DuplicateUserName;
     if (modelContainer.Users.Any(u => u.Email == Email))
         return MembershipCreateStatus.DuplicateEmail;
     User newUser = new User()
     {
         UserName = UserName,
         Password = GetMD5HashString(Password),
         Email = Email
     };
     modelContainer.Users.Add(newUser);
     if (modelContainer.DbSaveChanges() > 0)
         return MembershipCreateStatus.Success;
     else
         return MembershipCreateStatus.ProviderError;
 }
예제 #3
0
 public IQueryable<Sale> GetSales(User owner = null)
 {
     if (owner != null)
         return modelContainer.Sales.Where(s => s.User.Id == owner.Id);
     else
         return modelContainer.Sales;
 }