Beispiel #1
0
        void IMembersCommand.CreateMember(Member member)
        {
            if (member.VisibilitySettings == null)
            {
                member.VisibilitySettings = new VisibilitySettings();
            }
            if (member.Address == null)
            {
                member.Address = new Address();
            }

            PrepareCreate(member);
            member.Validate();
            _repository.CreateMember(member);
        }
Beispiel #2
0
        private static void CreateInvalidMember(Member member, LoginCredentials credentials, Guid?affiliateId)
        {
            // Check login credentials.

            if (LoginCredentialsQuery.DoCredentialsExist(credentials))
            {
                throw new DuplicateUserException();
            }

            // Set some defaults.

            member.IsEnabled   = true;
            member.AffiliateId = affiliateId;

            // Save.
            member.Prepare();

            MembersRepository.CreateMember(member);

            var candidate = new Candidate
            {
                Id                   = member.Id,
                Status               = Defaults.CandidateStatus,
                DesiredJobTypes      = Defaults.DesiredJobTypes,
                RelocationPreference = Defaults.RelocationPreference,
            };

            CandidatesCommand.CreateCandidate(candidate);

            if (affiliateId != null)
            {
                MemberAffiliationsCommand.SetAffiliation(member.Id, affiliateId.Value);
            }

            LoginCredentialsCommand.CreateCredentials(member.Id, credentials);

            //Update search

            //MemberSearchService.UpdateMember(member.Id);
        }
Beispiel #3
0
        private async Task <bool> CreateMemberAsync(CancellationToken ct = default(CancellationToken))
        {
            return(await Task.Run(() =>
            {
                bool output = false;
                string methodName = MethodBase.GetCurrentMethod().GetName();
                var sw = Stopwatch.StartNew();

                try
                {
                    Console.WriteLine("Insira o nome do novo membro.");
                    string authorName = Console.ReadLine();
                    if (string.IsNullOrEmpty(authorName))
                    {
                        Console.WriteLine("Nome inválido.");
                        return false;
                    }

                    output = _membersRepository.CreateMember(authorName);

                    return output;
                }
                catch (Exception ex)
                {
                    LogEngine.CLILogger.WriteToLog(LogLevels.Error, $"DAL.Exception: {JsonConvert.SerializeObject(ex)}");
                    return output = false;
                }
                finally
                {
                    sw.Stop();
                    string message = output == true ? "Membro inserido com sucesso" : "Não foi possivel adicionar o membro.";
                    Console.WriteLine(message);
                    LogEngine.CLILogger.WriteToLog(LogLevels.Debug, $"BLL.{methodName}(OUT={output}) in {sw.ElapsedMilliseconds}ms");
                }
            }, ct).ConfigureAwait(true));
        }