コード例 #1
0
ファイル: GerenciadorDeLeilao.cs プロジェクト: Cooperium/LPX
 public static Leilao GetLeilao(Int32 id)
 {
     using (var dao = new LpxDao())
     {
         return dao.Leilao.SingleOrDefault(l => l.Id == id);
     }
 }
コード例 #2
0
ファイル: HomeController.cs プロジェクト: Cooperium/LPX
        public ActionResult Index()
        {
            ViewBag.Message = User.Identity.Name;
            var dao = new LpxDao();
            var membershipUser = Membership.GetUser(User.Identity.Name);
            if (membershipUser != null)
                dao.Users.Single(u => u.Email == membershipUser.Email);

            return View();
        }
コード例 #3
0
ファイル: UserPersistence.cs プロジェクト: Cooperium/LPX
        public void PersistUser()
        {
            var user = new User();
            user.Email = "*****@*****.**";
            user.Empresa = "Cemig";
            user.NomeCompleto = "Pablo Corrêa Fonseca";
            user.Telefone = "91023792";

            LpxDao dao = new LpxDao();
            dao.Users.Add(user);
            dao.SaveChanges();
            dao.Dispose();

            LpxDao dao2 = new LpxDao();
            var retrieved = dao2.Users.Single(u => u.Email == "*****@*****.**");

            Assert.AreEqual(user.NomeCompleto , retrieved.NomeCompleto);
            Assert.AreEqual(user.Email, retrieved.Email);

            dao2.Users.Remove(retrieved);
            dao2.SaveChanges();
        }
コード例 #4
0
ファイル: AccountController.cs プロジェクト: Cooperium/LPX
        public ActionResult Registre(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                // Attempt to register the user
                MembershipCreateStatus createStatus;
                Membership.CreateUser(model.Email, model.Password, model.Email, null, null, true, null, out createStatus);

                if (createStatus == MembershipCreateStatus.Success)
                {
                    using (var dao = new LpxDao())
                    {
                        dao.Users.Add(new User() { Email = model.Email, Empresa = model.Empresa, NomeCompleto = model.NomeCompleto, Telefone = model.Telefone });
                        dao.SaveChanges();
                    }

                    FormsAuthentication.SetAuthCookie(model.Email, false /* createPersistentCookie */);
                    return RedirectToAction("Index", "Home");
                }
                else
                {
                    ModelState.AddModelError("", ErrorCodeToString(createStatus));
                }
            }

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