1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
   
   // <copyright file="DotNetHiringService.cs" company="SoftServe Inc.">
   //  Copyright (c) SoftServe Inc. All rights reserved.
   // </copyright>

   namespace SoftServe.Services
   {
        using System;
        using System.Collections.Generic;
        using System.Threading.Tasks;
        using System.Linq;
        using Jobs.Models;
        using Jobs.Models.Base.Contracts;
        using Jobs.Models.Enums;
        using SoftServe.Services.Base;
        using SoftServe.Services.Base.Contracts;
    
        public sealed class DotNetHiringService : HiringService, IHiringService
        {
            protected override HashSet<string> RequiredSkills => new HashSet<string> { "ASP.NET WebForms", "ASP.NET WebAPI", "C#", "SQL", "TSQL", "Design patterns", "Refactoring skills", "Passion" };
    
            protected override HashSet<string> OptionalSkills => new HashSet<string> { "Jira", "Confluence", "MongoDB", "Azure" };
    
            public DotNetHiringService(SoftServeService company)
                : base(company)
            {
            }
    
            public override async Task<AcquisitionResult> ProcessCandidate(DotNetDeveloper developer)
            {
                AcquisitionResult initialApprovalResult = await this.InitialApproval(developer);
    
                if (!initialApprovalResult.IsSuccessful)
                {
                    return await Task.FromResult<AcquisitionResult>(initialApprovalResult);
                }
    
                developer
                    .ReviewCompany("https://www.softserveinc.com")
                    .ReviewBenefits("https://www.jobs.bg/htmltemplates/189033/footer-new.jpg")
                    .ReviewOfficialJobAd("https://career.softserveinc.com/en-us/vacancy/15789-senior-net-software-engineer");

                var referralSecret = "C0d3";
                var extraPoints = this.CalculateExtraPoints(developer);

                developer.UpdateCv(referralSecret, extraPoints);
                developer.SendCv(to: "hr@softserve.bg", subject: referralSecret);
    
                HrPreviewResult previewResult = await base.company.PreviewCandidate(developer);
    
                if (!previewResult.IsSuccessful)
                {
                    return await Task.FromResult<AcquisitionResult>(new AcquisitionResult(isSuccessful: false, message: "Thank you for your application. At this current stage we decided to proceed with another candidate."));
                }
    
                Interview interview = base.company
                    .ContactDeveloper(developer)
                    .ScheduleInterview();
    
                if (interview.Status != InterviewStatusType.Scheduled)
                {
                    return await Task.FromResult<AcquisitionResult>(new AcquisitionResult(isSuccessful: false, message: "Thank you for your time, unfortunately, at this stage we are not able to proceed with scheduling interview."));
                }
    
                InterviewResult interviewResult = base.company.MakeInterview(developer);
    
                if (!interviewResult.IsSuccessful || !developer.IsInterested)
                {
                    return await Task.FromResult<AcquisitionResult>(new AcquisitionResult(isSuccessful: false, message: "Thank you for your participation. At this stage, we decided to proceed with another candidate."));
                }
    
                CompensationOffer offer = base.company.MakeCompensationOffer(developer);
                CompensationReviewResult result = await developer.ReviewCompensationOffer(offer);
    
                if (result.Status != JobOfferStatus.Accepted)
                {
                    return await Task.FromResult<AcquisitionResult>(new AcquisitionResult(isSuccessful: false, message: "Regrettably,  it seems that we will not work together. We wish you success in your professional achievements."));
                }
    
                base.company.Hire(developer);
    
                return await Task.FromResult<AcquisitionResult>(new AcquisitionResult(isSuccessful: true, message: "Congratulations, you are now part of our big family!"));
            }
    
            private async Task<AcquisitionResult> InitialApproval(IDeveloper developer)
            {
                AcquisitionResult initialApprovalResult = new AcquisitionResult(isSuccessful: true);
    
                if (!developer.IsInterested)
                {
                    initialApprovalResult = new AcquisitionResult(isSuccessful: false, message: "The candidate is not interested in the position.");
                }
    
                if (developer.SeniorityLevel != SeniorityLevelType.Senior)
                {
                    initialApprovalResult = new AcquisitionResult(isSuccessful: false, message: "Thank you for your time. Unfortunately, at this stage you don't match the required experience for a senior developer.");
                }
    
                var doesNotMeetRequiredSkills = !this.RequiredSkills.All(skill => developer.Skills.Contains(skill, StringComparer.InvariantCultureIgnoreCase));
    
                if (doesNotMeetRequiredSkills)
                {
                    initialApprovalResult = new AcquisitionResult(isSuccessful: false, message: "Thank you for your interest. Unfortunately, your experience does not match to our required skills.");
                }
    
                return await Task.FromResult<AcquisitionResult>(initialApprovalResult);
            }
    
            private int CalculateExtraPoints(IDeveloper developer)
            {
                var extraPoints = 0;
    
                foreach (var optionalSkill in this.OptionalSkills)
                {
                    foreach (var developerSkill in developer.Skills)
                    {
                        if (string.Equals(developerSkill, optionalSkill, StringComparison.CurrentCultureIgnoreCase))
                        {
                            extraPoints += 25;
                        }
                    }
                }
    
                return extraPoints;
            }
        }
   }