private static void InstallDbAndAddUser(string username, string password, string connString)
 {
     var person = new People
                     {
                         email = "*****@*****.**",
                         name = "Admin",
                         phone_number = "555-555-5555"
                     };
     var sm = new StaffMember
                 {
                     auth_name = username,
                     People = person
                 };
     sm.SetPassword(password);
     var repo = new ConferencewareRepository(connString);
     if (repo.DatabaseExists())
     {
         repo.DeleteDatabase();
     }
     repo.CreateDatabase();
     repo.AddStaffMember(sm);
     repo.Save();
 }
 private static void RemoveDb(string connString)
 {
     var repo = new ConferencewareRepository(connString);
     repo.DeleteDatabase();
 }
Ejemplo n.º 3
0
        public ActionResult LogOn(LogOnModel model, string returnUrl)
        {
            if (ModelState.IsValid)
            {
                if (MembershipService.ValidateUser(model.UserName, model.Password))
                {
                    FormsService.SignIn(model.UserName, model.RememberMe);
                    if (!String.IsNullOrEmpty(returnUrl))
                    {
                        return Redirect(returnUrl);
                    }
                    else
                    {
                        return RedirectToAction("Index", "Home");
                    }
                }
                else
                {
                    StaffMember sm =
                        new ConferencewareRepository().GetAllStaffMembers().SingleOrDefault(
                            x => x.auth_name == model.UserName);
                    ModelState.AddModelError("",
                                             "The user name or password provided is incorrect.");
                }
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }