Exemple #1
0
 public static Leilao GetLeilao(Int32 id)
 {
     using (var dao = new LpxDao())
     {
         return dao.Leilao.SingleOrDefault(l => l.Id == id);
     }
 }
Exemple #2
0
        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();
        }
Exemple #3
0
        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();
        }
Exemple #4
0
        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);
        }