public OparationDetailsUoW Create(UserModelUoW userDto) { ShopUser user = UserManager.FindByEmail(userDto.Email); if (user == null) { user = new ShopUser { Email = userDto.Email, UserName = userDto.Email }; var result = UserManager.Create(user, userDto.Password); if (result.Errors.Count() > 0) { return(new OparationDetailsUoW(false, result.Errors.FirstOrDefault(), "")); } // добавляем роль UserManager.AddToRole(user.Id, userDto.Role); // создаем профиль клиента UserProfileUoW clientProfile = new UserProfileUoW { Id = user.Id, Address = userDto.Address, Name = userDto.Name }; ProfileManager.Create(clientProfile); Save(); return(new OparationDetailsUoW(true, "Регистрация успешно пройдена", "")); } else { return(new OparationDetailsUoW(false, "Пользователь с таким логином уже существует", "Email")); } }
public void Create(UserProfileUoW _profile) { UserProfile profile = new UserProfile() { Id = _profile.Id, Address = _profile.Address, Name = _profile.Name }; Database.UserProfiles.Add(profile); Database.SaveChanges(); }