Ejemplo n.º 1
0
        public ActionResult UserRevise(User user)
        {
            if (user.FirstName != null && user.LastName != null && user.DateofBirth != 0 && this.ModelState.IsValid)
            {
                using (BookstoreEntities dbContext = new BookstoreEntities())
                {
                    dbContext.Users.Attach(user);
                    dbContext.Entry(user).State = System.Data.Entity.EntityState.Modified;
                    dbContext.SaveChanges();
                }

                return View("UserInfo", user);
            }
            else
            {
                return View("Error");
            }
        }
Ejemplo n.º 2
0
        public ActionResult UserRegister(User user)
        {
            User newUser = null;
            if (user.FirstName != null && user.LastName != null && user.DateofBirth != 0 && this.ModelState.IsValid)
            {
                using (BookstoreEntities dbContext = new BookstoreEntities())
                {
                    dbContext.Users.Add(user);
                    dbContext.SaveChanges();

                    newUser = dbContext.Users.SingleOrDefault(u => u.FirstName == user.FirstName && u.LastName == user.LastName && u.DateofBirth == user.DateofBirth);
                }

                return View("UserInfo", newUser);
            }
            else
            {
                return View("Error");
            }
        }