public IResult GetAllOpenings()
        {
            var result = new Result
            {
                Operation = Operation.Read,
                Status    = Status.Success
            };

            try
            {
                var allOpenings          = _openingRepository.GetAll();
                var openingIds           = allOpenings.Select(x => x.OpeningId).Distinct().ToList();
                var approvalTransactions = _approvalRepository.GetAllApprovalTransactions(openingIds).ToList();
                result.Body = allOpenings.Select(opening =>
                {
                    var approvalTransaction = approvalTransactions.FirstOrDefault(x => x.EntityId == opening.OpeningId);

                    var openingViewModel = new OpeningViewModel();
                    MapPrimaryandSecondarySkills(openingViewModel, opening);

                    if (approvalTransaction != null)
                    {
                        openingViewModel.IsApproved = approvalTransaction.IsApproved;
                        openingViewModel.Status     = approvalTransaction.ApprovalAction.ApprovalActionName;
                    }
                    return(openingViewModel.MapFromModel(opening));
                }).ToList();
            }
            catch (Exception e)
            {
                result.Message = e.Message;
                result.Status  = Status.Fail;
            }
            return(result);
        }
示例#2
0
        public void AddOpening(Opening opening)
        {
            IOpeningRepository repo = RepoFactory.CreateOpeningRepository();

            opening.JobId = GetOpeningID(repo.GetAll());
            repo.AddOpening(opening);
        }
示例#3
0
        public void EditOpening(Opening opening, Opening editedOpening)
        {
            IOpeningRepository repo = RepoFactory.CreateOpeningRepository();

            opening.JobId = GetOpeningID(repo.GetAll());

            repo.EditOpening(editedOpening);
        }
示例#4
0
        public ListOpeningResponses ListOpenings()
        {
            IOpeningRepository   repo     = RepoFactory.CreateOpeningRepository();
            ListOpeningResponses response = new ListOpeningResponses();
            var openings = repo.GetAll();

            if (openings.Count == 0)
            {
                response.Success = false;
                response.Message = "No openings found.";
            }
            else
            {
                response.Success  = true;
                response.openings = openings;
            }

            return(response);
        }