예제 #1
0
        public CandidateDTO AddCandidate(CandidateForManipulationDTO candidate)
        {
            var candidateToAdd = _mapper.Map <Candidate>(candidate);

            _candidateRepository.Add(candidateToAdd);
            if (!_candidateRepository.Save())
            {
                throw new Exception("Adding Candidate has been failed!");
            }

            return(_mapper.Map <CandidateDTO>(candidateToAdd));
        }
        public async Task <int> AddCandidate(CandidateDetailsWithSkills details)
        {
            var timeNow = DateTime.Now;

            var candidateObject = new Candidate()
            {
                FirstName   = details.FirstName,
                Surname     = details.LastName,
                DateOfBirth = details.DateOfBirth,
                Address1    = details.Address1,
                Town        = details.Town,
                Country     = details.Country,
                PostCode    = details.PostCode,
                PhoneHome   = details.PhoneHome,
                PhoneMobile = details.PhoneMobile,
                PhoneWork   = details.PhoneWork,
                CreatedDate = timeNow,
                UpdatedDate = timeNow
            };


            var candidateId = await _candidateRepository.Add(candidateObject);

            if (details.SkillIds != null)
            {
                int numSkills = details.SkillIds.Count;
                if (numSkills > 0)
                {
                    // If number of records created doesn't match size of input list consider rolling back entire transaction
                    var numRecords = await _candidateRepository.AddSkills(candidateId, details.SkillIds);
                }
            }

            return(candidateId);
        }
예제 #3
0
        public async Task <CandidateViewModel> AddNewCandidate(CandidateViewModel model)
        {
            var mapped   = _mapper.Map <Candidate>(model);
            var newmodel = await _candidateRepository.Add(mapped);

            return(_mapper.Map <CandidateViewModel>(newmodel));
        }
예제 #4
0
        public void Add(CandidateDTO candidateDto)
        {
            var candidate = new Candidate();

            candidate.Name  = candidateDto.Name;
            candidate.Image = candidateDto.Image;
            _candidateRepository.Add(candidate);
        }
        public async Task <Result> Handle(RegisterCandidateCommand request, CancellationToken cancellationToken)
        {
            var candidateName = new CandidateName(request.FirstName, request.LastName);

            _repo.Add(new Domain.Entities.Candidate(candidateName, request.Birthday, request.CurrentPosition, request.Note));
            await _repo.UnitOfWork.SaveEntitiesAsync();

            return(Result.Ok());
        }
예제 #6
0
        public HttpResponseMessage PostCandidate(Candidate item)
        {
            item = repository.Add(item);
            var response = Request.CreateResponse <Candidate>(HttpStatusCode.Created, item);

            string uri = Url.Link("DefaultApi", new { ApplicationId = item.ApplicationId });

            response.Headers.Location = new Uri(uri);
            return(response);
        }
        public Task Handle(ResumeReceivedEvent @event)
        {
            const string filePath  = "./Files/";
            var          candidate = _candidateRepository.GetCandidate(@event.Email, @event.Mobile);
            int          candidateId;

            if (candidate == null)
            {
                candidateId = _candidateRepository.Add(new Candidate()
                {
                    Email       = @event.Email,
                    Mobile      = @event.Mobile,
                    ResumeUrl   = @event.ResumeUrl,
                    CoverLetter = @event.CoverLetter
                });
            }
            else
            {
                candidate.ResumeUrl = @event.ResumeUrl;
                candidateId         = candidate.Id;
                _candidateRepository.Update(candidate);
            }
            if (!Directory.Exists($"{filePath}{candidateId}"))
            {
                Directory.CreateDirectory($"{filePath}{candidateId}");
            }

            File.Move($"{filePath}{@event.ResumeUrl}", $"{filePath}{candidateId}/{@event.FileName}", true);

            candidate           = _candidateRepository.GetCandidate(candidateId);
            candidate.ResumeUrl = $"{filePath}{candidateId}/{@event.FileName}";

            _candidateRepository.Update(candidate);

            var jobCandidate = _jobCandidateRepository.GetJobCandidate(@event.JobPostId, candidateId);
            int jobCandidateId;

            if (jobCandidate == null)
            {
                jobCandidateId = _jobCandidateRepository.Add(new JobCandidate()
                {
                    CandidateId     = candidateId,
                    JobPostId       = @event.JobPostId,
                    CandidateStatus = CandidateStatusEnum.New,
                    Source          = @event.Source,
                    ReceivedDate    = DateTime.UtcNow
                });

                var createScreeningCommand = new CreateScreeningCommand(jobCandidateId);

                _bus.SendCommand(createScreeningCommand);
            }

            return(Task.CompletedTask);
        }
예제 #8
0
        public ActionResult <CandidateDTO> PostCandidate(CandidateDTO candidate)
        {
            log.LogInformation("Create candidate");

            try
            {
                candidateRepository.Add(candidate.ToEntity());

                log.LogInformation("Create successfully - new CandidateId: " + candidate.CandidateId);
            }
            catch (System.Exception ex)
            {
                log.LogError("Error creating candidate: " + ex.Message ?? ex.InnerException.Message);
            }

            return(CreatedAtAction("GetCandidate", new { id = candidate.CandidateId }, candidate));
        }
예제 #9
0
        public async Task <CreateCandidateCommandResponse> Handle(CreateCandidateCommandRequest request, CancellationToken cancellationToken)
        {
            CreateCandidateCommandResponse result = null;

            try
            {
                Candidate candidate = await _candidateRepository.GetByName(request.Nome);

                if (candidate == null)
                {
                    candidate = new Candidate
                    {
                        Id            = Guid.NewGuid(),
                        Nome          = request.Nome,
                        Telefone      = request.Telefone,
                        UrlLinkedin   = request.UrlLinkedin,
                        UsuarioGithub = request.UsuarioGithub,
                        Created       = DateTime.Now,
                        Updated       = DateTime.Now
                    };

                    await _candidateRepository.Add(candidate);
                }
                else
                {
                    candidate.Updated = DateTime.Now;

                    await _candidateRepository.Update(candidate);
                }

                result = new CreateCandidateCommandResponse
                {
                    Id            = candidate.Id,
                    Nome          = candidate.Nome,
                    Telefone      = candidate.Telefone,
                    UrlLinkedin   = candidate.UrlLinkedin,
                    UsuarioGithub = candidate.UsuarioGithub
                };

                return(await Task.FromResult(result));
            }
            catch (Exception)
            {
                return(await Task.FromResult(result));
            }
        }
예제 #10
0
        public async Task <ValidationResult> Handle(RegisterCandidateCommand message, CancellationToken cancellationToken)
        {
            if (!message.IsValid())
            {
                return(message.ValidationResult);
            }

            var candidate           = new Candidate(message.Id, message.FirstName, message.LastName, message.BirthDate, message.Gender, message.CPF);
            var hasCandidateThisCpf = _candidateRepository.HasCandidateWithThisCPF(message.CPF);

            if (hasCandidateThisCpf)
            {
                AddError("Já existe um candidato com esse CPF cadastrado");
                return(ValidationResult);
            }

            await _candidateRepository.Add(candidate);

            candidate.AddEvent(new RegisteredCandidateEvent(message.Id, message.CPF, message.FirstName, message.LastName, message.Email, message.BirthDate, message.Gender));

            return(await SaveChanges(_candidateRepository.UnitOfWork));
        }
예제 #11
0
        public async Task <bool> Handle(CreateCandidateCommand request, CancellationToken cancellationToken)
        {
            Expression <Func <Offer, object> >[] includes = new Expression <Func <Offer, object> >[] {
                x => x.Candidates
            };
            var offer = await _offerRepository.GetByIdAsync(request.OfferId, includes);

            if (offer == null)
            {
                throw new ApiException("The offer can't be found.", StatusCodes.Status404NotFound);
            }

            if (offer.Candidates.Any(x => x.Email == request.Email))
            {
                throw new ApiException("Sorry you already apply on this offer", StatusCodes.Status400BadRequest);
            }

            var candidate = new Candidate(request.Name, request.Email, request.OfferId);

            _candidateRepository.Add(candidate);

            return(await _candidateRepository.UnitOfWork.SaveEntitiesAsync());
        }
 public void CreateCandidate(Candidate candidate)
 {
     candidateRepository.Add(candidate);
 }
예제 #13
0
 public async Task Add(CandidateDataViewModel candidateDataDto)
 {
     await _candidateRepository.Add(_mapper.Map <Candidate>(candidateDataDto));
 }
예제 #14
0
 public IActionResult Post(Candidate candidate)
 {
     _candidateRepo.Add(candidate);
     return(CreatedAtAction("GetCandidate", new { id = candidate.Id }, candidate));
 }
예제 #15
0
        /// <summary>
        /// Seed method attempts to intsert the initial data into the database everytime when database is being updated after migration
        /// </summary>
        /// <param name="context">Database context on which seed method is being called (Not used in this scenario because repositories are used to insert the data)</param>
        protected override void Seed(RAMS.Data.DataContext context)
        {
            // Add users
            using (var applicationDbContext = new ApplicationDbContext())
            {
                var userStore = new UserStore <ApplicationUser>(applicationDbContext);

                var userManager = new UserManager <ApplicationUser>(userStore);

                if (userManager.FindByName("john.doe") == null)
                {
                    var users = GetUsers();

                    foreach (var user in users)
                    {
                        userManager.Create(user, "123RAMSApp!");

                        // Add user claims for each user
                        if (user.UserName == "superuser")
                        {
                            userManager.AddClaim(user.Id, new Claim("FullName", "superuser"));
                            userManager.AddClaim(user.Id, new Claim("Role", "Manager"));
                            userManager.AddClaim(user.Id, new Claim("UserType", "Admin"));
                            userManager.AddClaim(user.Id, new Claim("UserStatus", "Active"));
                        }
                        else if (user.UserName == "john.doe")
                        {
                            userManager.AddClaim(user.Id, new Claim("FullName", "John Doe"));
                            userManager.AddClaim(user.Id, new Claim("Role", "Manager"));
                            userManager.AddClaim(user.Id, new Claim("UserType", "Agent"));
                            userManager.AddClaim(user.Id, new Claim("UserStatus", "Active"));
                        }
                        else if (user.UserName == "james.smith")
                        {
                            userManager.AddClaim(user.Id, new Claim("FullName", "James Smith"));
                            userManager.AddClaim(user.Id, new Claim("Role", "Employee"));
                            userManager.AddClaim(user.Id, new Claim("UserType", "Agent"));
                            userManager.AddClaim(user.Id, new Claim("UserStatus", "Active"));
                        }
                        else if (user.UserName == "mary.watson")
                        {
                            userManager.AddClaim(user.Id, new Claim("FullName", "Mary Watson"));
                            userManager.AddClaim(user.Id, new Claim("Role", "Employee"));
                            userManager.AddClaim(user.Id, new Claim("UserType", "Agent"));
                            userManager.AddClaim(user.Id, new Claim("UserStatus", "Active"));
                        }
                        else if (user.UserName == "tommy.jordan")
                        {
                            userManager.AddClaim(user.Id, new Claim("FullName", "Tommy Jordan"));
                            userManager.AddClaim(user.Id, new Claim("Role", "Employee"));
                            userManager.AddClaim(user.Id, new Claim("UserType", "Admin"));
                            userManager.AddClaim(user.Id, new Claim("UserStatus", "Active"));
                        }
                        else if (user.UserName == "kathy.doe")
                        {
                            userManager.AddClaim(user.Id, new Claim("FullName", "Kathy Doe"));
                            userManager.AddClaim(user.Id, new Claim("Role", "Employee"));
                            userManager.AddClaim(user.Id, new Claim("UserType", "Admin"));
                            userManager.AddClaim(user.Id, new Claim("UserStatus", "Active"));
                        }
                        else if (user.UserName == "jimmy.thomson")
                        {
                            userManager.AddClaim(user.Id, new Claim("FullName", "Jimmy Thomson"));
                            userManager.AddClaim(user.Id, new Claim("Role", "Employee"));
                            userManager.AddClaim(user.Id, new Claim("UserType", "Client"));
                            userManager.AddClaim(user.Id, new Claim("UserStatus", "Active"));
                        }
                        else if (user.UserName == "nancy.clinton")
                        {
                            userManager.AddClaim(user.Id, new Claim("FullName", "Nancy Clinton"));
                            userManager.AddClaim(user.Id, new Claim("Role", "Employee"));
                            userManager.AddClaim(user.Id, new Claim("UserType", "Client"));
                            userManager.AddClaim(user.Id, new Claim("UserStatus", "Active"));
                        }
                    }
                }
            }

            // Add departments
            if (!departmentRepository.GetAll().Any())
            {
                GetDepartments().ForEach(d => departmentRepository.Add(d));

                unitOfWork.Commit();
            }

            // Add agents
            if (!agentRepository.GetAll().Any())
            {
                GetAgents().ForEach(a => agentRepository.Add(a));

                unitOfWork.Commit();
            }

            // Add clients
            if (!clientRepository.GetAll().Any())
            {
                GetClients().ForEach(c => clientRepository.Add(c));

                unitOfWork.Commit();
            }

            // Add admins
            if (!adminRepository.GetAll().Any())
            {
                GetAdmins().ForEach(a => adminRepository.Add(a));

                unitOfWork.Commit();
            }

            // Add categories
            if (!categoryRepository.GetAll().Any())
            {
                GetCategories().ForEach(c => categoryRepository.Add(c));

                unitOfWork.Commit();
            }

            // Add positions
            if (!positionRepository.GetAll().Any())
            {
                GetPositions().ForEach(p => positionRepository.Add(p));

                unitOfWork.Commit();
            }

            // Add candidates
            if (!candidateRepository.GetAll().Any())
            {
                GetCandidates().ForEach(c => candidateRepository.Add(c));

                unitOfWork.Commit();
            }

            // Add interiews
            if (!interviewRepository.GetAll().Any())
            {
                GetInterviews().ForEach(i => interviewRepository.Add(i));

                unitOfWork.Commit();
            }

            // Add notifications
            if (!notificationRepository.GetAll().Any())
            {
                GetNotifications().ForEach(n => notificationRepository.Add(n));

                unitOfWork.Commit();
            }
        }
예제 #16
0
 public void AddCandidate(params Data.AppTrackEntities.candidate[] candidates)
 {
     //TO DO: Validation and error handling
     _candRepository.Add(candidates);
 }