public static RegistrationResponce RegisterUser(RegistrationRequest registrationRequest) { ICompany company = _configuration.Container.GetInstance <ICompany>(); var userToAdd = _configuration.Container.GetInstance <IUser>(); var keyGen = _configuration.Container.GetInstance <IKeyGenerator>(); string message = ""; if (!IsValidatedSource(registrationRequest.Source, company, out ISource sourceFromDb)) { return(new RegistrationResponce(false, "Неккоректные ключи источника.")); } if (!IsExistenceUserType(registrationRequest.TypeId, company, out IUserType userTypeFromDb)) { return(new RegistrationResponce(false, "Неккоректный тип пользователя.")); } if (!FullValidateUserIdentifiers(registrationRequest.Identifiers, company, out List <IUserIdentifier> userIdentifiersToAdd, ref message)) { return(new RegistrationResponce(false, message)); } userToAdd.CurrentSecretKey = keyGen.NewKey(); userToAdd.FirstName = registrationRequest.FirstName; userToAdd.MiddleName = registrationRequest.MiddleName; userToAdd.LastName = registrationRequest.LastName; userToAdd.ChildrenQuantity = registrationRequest.ChildrenQuantity; userToAdd.Age = DateTime.Now.Year - registrationRequest.DateOfBirth.Year; userToAdd.DateOfBirth = registrationRequest.DateOfBirth; userToAdd.Type = userTypeFromDb; userToAdd.Source = sourceFromDb; userToAdd.UserIdentifiers = userIdentifiersToAdd; company.CreateUser(userToAdd); return(new RegistrationResponce(true, "Пользователь успешно зарегистрирован")); }