Пример #1
0
        public IActionResult Accept(int connid)
        {
            Connect invite = _context.connections.SingleOrDefault(conn => conn.connectid == connid);

            invite.Accepted = true;
            _context.SaveChanges();
            return(RedirectToAction("Profile"));
        }
Пример #2
0
 public IActionResult Register(UserViewModel user)
 {
     System.Console.WriteLine("start");
     if (ModelState.IsValid)
     {
         System.Console.WriteLine("valid");
         string UserEmail  = user.Email;
         User   LookupUser = _context.users.SingleOrDefault(login => login.Email == UserEmail);
         if (LookupUser == null)
         {
             PasswordHasher <UserViewModel> Hasher = new PasswordHasher <UserViewModel>();
             user.Password = Hasher.HashPassword(user, user.Password);
             System.Console.WriteLine("length is {0}", user.Password.Length);
             User NewUser = new User
             {
                 UserName    = user.UserName,
                 Email       = user.Email,
                 Password    = user.Password,
                 Description = user.Description,
                 created_at  = DateTime.Now,
                 updated_at  = DateTime.Now
             };
             _context.Add(NewUser);
             _context.SaveChanges();
             NewUser = _context.users.SingleOrDefault(login => login.Email == UserEmail);
             HttpContext.Session.SetInt32("userid", NewUser.userid);
             HttpContext.Session.SetString("email", NewUser.Email);
             System.Console.WriteLine("Iz guud!");
             // return RedirectToAction("Plan", "Wedding");
             return(RedirectToAction("ShowUsers"));
         }
         else
         {
             ModelState.AddModelError("email", "This Email is already registered.");
             ViewBag.errors = ModelState.Values;
             return(View("~/Views/User/LogReg.cshtml", user));
         }
     }
     else
     {
         System.Console.WriteLine("Iz nah guud.");
         return(View("~/Views/User/LogReg.cshtml", user));
     }
 }