Ejemplo n.º 1
0
        public IEnumerable <Models.ResponseModels.Task.Task> GetTasksBasedOnApplicantSkills()
        {
            var user      = _commonService.GetCurrentUserContext();
            var skillList = new List <int>();

            if (user != null && user.SkillSet != null)
            {
                foreach (var skill in user.SkillSet)
                {
                    skillList.Add(skill.Id);
                }
                var dbtaskSkills     = _contributorRepository.GetTasksBasedOnApplicantSkills(skillList, user.UserId);
                var dbTaskApplicants = _contributorRepository.GetAppliedTasks(user.UserId);
                var tasks            = _taskSkillModelFactory.CreateModelList <Models.ResponseModels.Task.Task>(dbtaskSkills);
                //Map Applied field
                foreach (var appliedTask in dbTaskApplicants)
                {
                    var taskObj = tasks.Where(x => x.Id == appliedTask.TASK_ID).FirstOrDefault();
                    if (taskObj != null)
                    {
                        taskObj.IsApplied = true;
                    }
                }
                return(tasks);
            }
            return(null);
        }
Ejemplo n.º 2
0
        public int UpsertTask(TaskRequest taskRequest)
        {
            var result = 0;

            if (taskRequest.ActionType == ActionType.Insert)
            {
                taskRequest.WBSCode = string.IsNullOrWhiteSpace(taskRequest.WBSCode)
                    ? "WBS00000-00-00-00-0000"
                    : taskRequest.WBSCode;

                var dbTask = _taskModelFactory.CreateModel <TaskRequest>(taskRequest);
                MapAuditFields <task>(ActionType.Insert, dbTask);
                if (taskRequest.SelectedTaskType == "2" ||
                    taskRequest.SelectedTaskType == "3")
                {
                    if (taskRequest.SkillSet == null ||
                        !taskRequest.SkillSet.Any())
                    {
                        var listOfSkills = new List <int>();

                        var skillName = taskRequest.SelectedTaskType == "2"
                            ? Constants.FirmInitiativeSkillRecord
                            : Constants.IndustryInitiativeSkillRecord;

                        var matchedSkill = _taskRepository.GetSkillByName(skillName);

                        listOfSkills.Add(matchedSkill != null
                            ? matchedSkill.ID
                            : default(int));

                        taskRequest.SkillSet = listOfSkills;
                    }
                }
                var dbTaskSkills = _taskSkillModelFactory.CreateModelList(taskRequest.SkillSet);
                foreach (var dbTaskSkill in dbTaskSkills)
                {
                    MapAuditFields <taskskill>(ActionType.Insert, dbTaskSkill);
                }
                result = _taskRepository.InsertTask(dbTask, dbTaskSkills);

                if (taskRequest.SelectedTaskType == "2" &&
                    result == 2)
                {
                    var currentUser = _commonService.GetCurrentUserContext();

                    var offeringRecipients = _commonService.GetFINotificationRecipientsForOffering(
                        Convert.ToInt32(taskRequest.SelectedOffering));

                    offeringRecipients = offeringRecipients != null && offeringRecipients.Any()
                        ? offeringRecipients
                        : _commonService.GetDefaultConsultingMailboxes();

                    var offering = _commonService.GetOfferings()
                                   .Where(x => x.Id == Convert.ToInt32(taskRequest.SelectedOffering))
                                   .Select(x => x.Description)
                                   .FirstOrDefault();

                    var mailMessage = EmailHelper.PostNewFINotification(taskRequest.ProjectName,
                                                                        taskRequest.Hours.ToString(),
                                                                        taskRequest.Description,
                                                                        taskRequest.OnBoardingDate,
                                                                        currentUser.EmailId,
                                                                        offeringRecipients,
                                                                        offering);
                    var emailTracker = new EmailTracker
                    {
                        ToAddresses = ConfigurationManager.AppSettings["DcodeEmailId"],
                        Subject     = mailMessage.Subject,
                        Body        = mailMessage.Body,
                        TaskId      = taskRequest.Id,
                        Source      = ApplicationSource.WebApp.ToString()
                    };

                    if (currentUser.EmailId != null)
                    {
                        emailTracker.CcAddresses.Add(currentUser.EmailId);
                    }


                    if (offeringRecipients != null && offeringRecipients.Any())
                    {
                        emailTracker.BccAddresses.AddRange(offeringRecipients);
                    }

                    _emailTrackerService.InsertEmail(emailTracker);
                }
            }
            else if (taskRequest.ActionType == ActionType.Update)
            {
                var dbTask = _taskModelFactory.CreateModel <TaskRequest>(taskRequest);
                MapAuditFields <task>(ActionType.Update, dbTask);
                result = _taskRepository.UpdateTask(dbTask);
            }
            return(result);
        }