예제 #1
0
        public ActionResult Register(UserRegisterModel model)
        {
            var exist = _userService.IsExist(model.Login, model.PasswordHash);

            if (exist || !ModelState.IsValid)
            {
                return(StatusCode(409));
            }
            var user = new User
            {
                Login        = model.Login,
                Email        = model.Email,
                PasswordHash = model.PasswordHash
            };

            _userService.Create(user);
            var dictionaries = _vocabularyService.GetAll();

            if (dictionaries != null)
            {
                foreach (var dictionary in dictionaries)
                {
                    _vocabularyService.ConnectUserWithDictionary(user.Id, dictionary.Id);
                }
            }

            return(Ok());
        }
예제 #2
0
        public ActionResult AddDictionaryForUser(int id)
        {
            var userId = int.Parse(User.FindFirst(TokenClaims.Id).Value);

            _vocabularyService.ConnectUserWithDictionary(userId, id);
            return(Ok());
        }