Пример #1
0
        public IActionResult UserRegistration([FromBody] User user)
        {
            var userinDb = _context.Users.SingleOrDefault(u =>
                                                          u.Email == user.Email);
            var userinDb2 = _context.Users.SingleOrDefault(u =>
                                                           u.Username == user.Username);

            if (userinDb != null)
            {
                return(Ok(_sendIncorrectEmailMessage()));
            }
            if (userinDb2 != null)
            {
                return(Ok(_sendIncorrectUsernameMessage()));
            }


            user.Password = Crypto.HashPassword(user.Password);

            using (var context = new JustFinishedContext())
            {
                context.Users.Add(user);
                context.SaveChanges();
            }
            return(Ok(user));
        }
Пример #2
0
        public IActionResult aInvitations([FromBody] User_Project user_project)
        {
            _context.Users_Projects.Add(user_project);
            var userInDb = _context.Users_Invites.SingleOrDefault(u => u.Email == user_project.Email && u.ProjectId == user_project.ProjectId);

            _context.Users_Invites.Remove(userInDb);
            _context.SaveChanges();
            return(Ok(true));
        }
Пример #3
0
 public IActionResult Register([FromBody] Project project)
 {
     _context.Projects.Add(project);
     _context.SaveChanges();
     return(Ok(project.Id));
 }