예제 #1
0
 public ActionResult Edit(User user)
 {
     if (ModelState.IsValid)
     {
         context.Entry(user).State = EntityState.Modified;
         context.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(user);
 }
예제 #2
0
        public ActionResult Create(User user)
        {
            //TODO: check email deosnt exist already
            if (ModelState.IsValid)
            {
                context.Users.Add(user);
                context.SaveChanges();

                return RedirectToAction("Index");
            }

            return View(user);
        }
예제 #3
0
        public void Can_specify_user_as_owner()
        {
            var sut = new Card();
            var user = new User();
            var userLink = new UserLink { User = user, LinkType = UserLinkType.Owner };

            sut.UserLinks.Add(userLink);

            Assert.AreEqual(1, sut.UserLinks.Count);
        }
예제 #4
0
        public void Can_add_a_user_to_a_card()
        {
            var sut = new Card();
            var user = new User();
            var userLink = new UserLink { User = user };

            sut.UserLinks.Add(userLink);

            Assert.AreEqual(1, sut.UserLinks.Count);
        }
예제 #5
0
 public void Can_add_a_user()
 {
     var sut = new User();
     Assert.IsNotNull(sut);
 }
예제 #6
0
        public ActionResult Signup(SignupViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new User
                {
                    Name = model.Name,
                    Email = model.Email,
                    Password = model.Password, //TODO: Hash this
                    Created = DateTime.Now,
                    Modified = DateTime.Now
                };
                context.Users.Add(user);
                context.SaveChanges();

                var newUser = context.Users.SingleOrDefault(x => x.Email == user.Email && x.Password == model.Password);
                if (newUser != null) FormsAuthentication.SetAuthCookie(newUser.Id.ToString(), user.RememberMe);

                return RedirectToAction("Index", "Dashboard");
            }

            return View(model);
        }
예제 #7
0
        public ActionResult Login(User model)
        {
            if (ModelState.IsValid)
            {
                var user = context.Users.SingleOrDefault(x => x.Email == model.Email && x.Password == model.Password);

                if (user != null)
                {
                    FormsAuthentication.SetAuthCookie(user.Id.ToString(), user.RememberMe);
                    return RedirectToAction("Index", "Dashboard");
                }
                else
                {
                    ModelState.AddModelError("", "Login data is incorrect!");
                }
            }
            return View(model);
        }