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()); }
public ActionResult <List <VocabularyWithWords> > GetDictionariesAll() { var userId = int.Parse(User.FindFirst(TokenClaims.Id).Value); var dictionariesAll = _vocabularyService.GetAll(); if (dictionariesAll == null) { return(NotFound()); } List <VocabularyWithWords> models = new List <VocabularyWithWords>(); foreach (var item in dictionariesAll) { var obj = new VocabularyWithWords { Id = item.Id, IsPrivate = item.IsPrivate, Name = item.Name, LevelId = item.LevelId, Words = _wordService.GetByVocabulary(userId, item.Id) }; models.Add(obj); } return(models); }