public static JobFunction CreateJobFunction(string jobFunctionId)
        {
            JobFunction jobFunction = new JobFunction();

            jobFunction.JobFunctionId = jobFunctionId;
            return(jobFunction);
        }
Ejemplo n.º 2
0
        public async Task <JobFunction> Create(JobFunction JobFunction)
        {
            JobFunction.Code = JobFunction.Code.FormatCode();
            string id = await m_JobFunctionRepositoryM.Create(JobFunction);

            JobFunction.Id = id;
            return(JobFunction);
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Get(string id, string code)
        {
            JobFunction JobFunction = null;

            if (!string.IsNullOrWhiteSpace(id))
            {
                JobFunction = await m_JobFunctionBusiness.Get(id);
            }
            else
            {
                JobFunction = await m_JobFunctionBusiness.GetByCode(code);
            }
            return(Json(JobFunction));
        }
Ejemplo n.º 4
0
        public void GetAllJobFunctionsShoudReturnAll()
        {
            //Arrange
            JobFunction a = new JobFunction()
            {
                Id = 1,
                JobFunctionTitle    = "title1",
                RequiredCompetences = "1,2,11",
            };
            JobFunction b = new JobFunction()
            {
                Id = 2,
                JobFunctionTitle    = "title2",
                RequiredCompetences = "1,2,11",
            };
            JobFunction c = new JobFunction()
            {
                Id = 3,
                JobFunctionTitle    = "title3",
                RequiredCompetences = "1,2,11",
            };
            List <JobFunction> jobfunctionList = new List <JobFunction>()
            {
                a, b, c
            };

            //Mock
            mockFunctionRepository.Setup(repo => repo.GetAllList()).Returns(jobfunctionList);



            //Act
            ListJobFunctionDTO output = sutJobFunctionService.GetAllJobFunctions();
            bool result = true;

            for (int i = 1; i < 3; i++)
            {
                if (jobfunctionList[i].Id != output.JobFunctionList[i].JobFunctionID)
                {
                    result = false;
                    break;
                }
            }

            //Assert
            Assert.AreEqual(true, result);
        }
Ejemplo n.º 5
0
        public IActionResult Post([FromBody] CreateEditViewModel model)
        {
            var data = new JobFunction();

            if (model is null)
            {
                return(BadRequest("Data is null."));
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }
            _mapper.Map(model, data);
            _JobFunctionProvider.Add(data);
            return(Ok(data));
        }
Ejemplo n.º 6
0
        private async void SaveTaskToolButton_Clicked(object sender, EventArgs e)
        {
            if (addedTaskTools.Count > 0)
            {
                bool successfulInsert = false;

                foreach (var item in addedTaskTools)
                {
                    JobFunction jobFunction = new JobFunction()
                    {
                        JobID         = passedJob.ID,
                        TaskID        = item.ID,
                        DateScheduled = passedDate
                    };
                    try
                    {
                        await App.mobileService.GetTable <JobFunction>().InsertAsync(jobFunction);

                        successfulInsert = true;
                    }
                    catch (Exception)
                    {
                        throw;
                    }
                }
                if (successfulInsert)
                {
                    this.Navigation.RemovePage(this.Navigation.NavigationStack[this.Navigation.NavigationStack.Count - 2]);

                    await this.Navigation.PopAsync();

                    await Application.Current.MainPage.DisplayAlert("Success", "Job scheduled! Dont forget to assign workers for them to see this job you scheduled!", "Ok");


                    await FormModel.FullAzureDatabaseQuery();

                    await Navigation.PushAsync(new OwnerPages.JobPage());
                }
            }
            else
            {
                await Application.Current.MainPage.DisplayAlert("Error", "Job must have at least one task.", "Ok");
            }
        }
Ejemplo n.º 7
0
        public void GetJobFunctionByIdShoudReturnNull()
        {
            //Arrange
            JobFunction a = new JobFunction()
            {
                Id = 1,
                JobFunctionTitle    = "title1",
                RequiredCompetences = "1,2,11",
            };
            JobFunction b = new JobFunction()
            {
                Id = 2,
                JobFunctionTitle    = "title2",
                RequiredCompetences = "1,2,11",
            };
            JobFunction c = new JobFunction()
            {
                Id = 3,
                JobFunctionTitle    = "title3",
                RequiredCompetences = "1,2,11",
            };
            List <JobFunction> jobfunctionList = new List <JobFunction>()
            {
                a, b, c
            };

            //Mock
            mockFunctionRepository.Setup(repo => repo.FirstOrDefault(1)).Returns(a);
            mockFunctionRepository.Setup(repo => repo.FirstOrDefault(2)).Returns(b);
            mockFunctionRepository.Setup(repo => repo.FirstOrDefault(3)).Returns(c);



            //Act
            JobFunctionDTO output = sutJobFunctionService.GetJobFunctionById(10);

            //Assert
            Assert.Null(output);
            //Assert.IsNull(output.JobFunctionTitle); //bug when id is out of range, please fix it
        }
Ejemplo n.º 8
0
        public void GetJobFunctionByIdShoudReturnSameJobfunction()
        {
            //Arrange
            JobFunction a = new JobFunction()
            {
                Id = 1,
                JobFunctionTitle    = "title1",
                RequiredCompetences = "1,2,11",
            };
            JobFunction b = new JobFunction()
            {
                Id = 2,
                JobFunctionTitle    = "title2",
                RequiredCompetences = "1,2,11",
            };
            JobFunction c = new JobFunction()
            {
                Id = 3,
                JobFunctionTitle    = "title3",
                RequiredCompetences = "1,2,11",
            };
            List <JobFunction> jobfunctionList = new List <JobFunction>()
            {
                a, b, c
            };

            //Mock
            mockFunctionRepository.Setup(repo => repo.FirstOrDefault(1)).Returns(a);
            mockFunctionRepository.Setup(repo => repo.FirstOrDefault(2)).Returns(b);
            mockFunctionRepository.Setup(repo => repo.FirstOrDefault(3)).Returns(c);



            //Act
            JobFunctionDTO output = sutJobFunctionService.GetJobFunctionById(2);

            //Assert
            Assert.AreEqual("title2", output.JobFunctionTitle);
        }
Ejemplo n.º 9
0
        private List <string> GetErrors(JobFunction item, ConfigurationPath configPath)
        {
            var errors = new List <string>();

            var jobDefinition = configPath.Client.JobDefinition;

            if (!jobDefinition.Any(j => j.Name.Equals(item.Name, StringComparison.CurrentCultureIgnoreCase)))
            {
                errors.Add($"Job Function is not in the Job Definition.");
            }

            if (item.PercentageOfTime == null || !item.PercentageOfTime.Any())
            {
                errors.Add("There are no elements in the PercentageOfTime.");
            }
            else
            {
                AddMonthDuplicationsError(item.PercentageOfTime, "PercentageOfTime", ref errors);
            }

            return(errors);
        }
Ejemplo n.º 10
0
 ///<summary>Adds the value of the <c>&lt;Assignment&gt;</c> element.</summary>
 /// <param name="SchoolInfoRefId">References SchoolInfo object to determine school in which this assignment pertains.</param>
 /// <param name="GradeLevels">A GradeLevels</param>
 /// <param name="JobFunction">A JobFunction</param>
 ///<remarks>
 /// <para>This form of <c>setAssignment</c> is provided as a convenience method
 /// that is functionally equivalent to the method <c>AddAssignment</c></para>
 /// <para>Version: 2.6</para>
 /// <para>Since: 1.5r1</para>
 /// </remarks>
 public void AddAssignment(string SchoolInfoRefId, GradeLevels GradeLevels, JobFunction JobFunction)
 {
     AddChild(ProfdevDTD.EMPLOYEEASSIGNMENTS_ASSIGNMENT, new EmplAssignment(SchoolInfoRefId, GradeLevels, JobFunction));
 }
        public void WhenCompetencyDoesNotHaveJobFunctionAtAll_ThenFindCompetencyIsCalledOnceAndViewModelHasExpectedValues()
        {
            // Arrange
            Competency selectedCompetency = null;

            string templateId = "B7F16780-227C-46FC-A7A1-7AADF91BBECA";

            var savedTemplate = new Template
            {
                Id               = "B7F16780-227C-46FC-A7A1-7AADF91BBECA",
                CompetencyId     = 13,
                JobFunctionLevel = 3,
                Skills           = new List <SkillTemplate> {
                    new SkillTemplate
                    {
                        SkillId = 228, Questions = new List <string>()
                    },
                    new SkillTemplate
                    {
                        SkillId = 289, Questions = new List <string>()
                    }
                },
                Exercises = new List <string>()
            };

            var savedJobFunction = new JobFunction
            {
                Id           = 15,
                MnemonicBase = "D",
                Track        = 0,
                Name         = "Software Engineering"
            };

            var savedJobLevels = new List <Level>
            {
                new Level {
                    Id = 1, IsEligibleForAsmt = false, JobTitles = new List <string> {
                        "Junior Software Engineer"
                    }
                },
                new Level {
                    Id = 2, IsEligibleForAsmt = false, JobTitles = new List <string> {
                        "Software Engineer"
                    }
                },
                new Level {
                    Id = 3, IsEligibleForAsmt = true, JobTitles = new List <string> {
                        "Senior Software Engineer"
                    }
                }
            };

            var savedJobFunctionDocument = new JobFunctionDocument
            {
                Id          = "B63BE6A3-64E3-43D9-A200-4577ADFE26E5",
                JobFunction = savedJobFunction,
                Levels      = savedJobLevels
            };

            var savedCompetencies = new List <Competency>
            {
                new Competency {
                    Id = 1, Code = "DotNET", ParentId = null, IsSelectable = false, JobFunctions = new List <int>(), Name = ".NET"
                },
                new Competency {
                    Id = 13, Code = "DotNET-Azure", ParentId = 1, IsSelectable = true, JobFunctions = new List <int>(), Name = "Azure Development"
                }
            };

            var queryJobFunction = new Mock <IJobFunctionQueryRepository>();

            queryJobFunction
            .Setup(method => method.FindJobTitleByLevel(It.IsAny <int>(), It.IsAny <int>()))
            .ReturnsAsync((int jobFunctionId, int jobFunctionLevel) => savedJobFunctionDocument.Levels.Where(item => item.Id == jobFunctionLevel).First().JobTitles.FirstOrDefault());

            var querySkillMatrix = new Mock <ISkillMatrixQueryRepository>();

            querySkillMatrix
            .Setup(method => method.FindWithinSkills(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <int[]>()))
            .ReturnsAsync(() => new List <Skill>());

            var queryCompetency = new Mock <ICompetencyQueryRepository>();

            queryCompetency
            .Setup(method => method.FindCompetency(It.IsAny <int>()))
            .ReturnsAsync((int competencyId) =>
            {
                selectedCompetency = savedCompetencies.Where(item => item.Id == competencyId).FirstOrDefault();
                return(selectedCompetency);
            });

            var queryTemplate = new Mock <IQueryRepository <Template, string> >();

            queryTemplate
            .Setup(method => method.FindById(It.IsAny <string>()))
            .ReturnsAsync(savedTemplate);

            var queryQuestion = new Mock <IQuestionQueryRepository>();
            var queryExercise = new Mock <IExerciseQueryRepository>();

            var controllerUnderTest = new QueryTemplateController(querySkillMatrix.Object, queryTemplate.Object, queryJobFunction.Object, queryCompetency.Object, queryQuestion.Object, queryExercise.Object);

            // Act
            var actionResult = controllerUnderTest.Get(templateId).Result;

            // Assert
            Assert.That(actionResult, Is.Not.Null);
            Assert.That(actionResult, Is.TypeOf <OkNegotiatedContentResult <TemplateViewModel> >());
            queryCompetency.Verify(method => method.FindCompetency(It.IsAny <int>()), Times.Exactly(2));
            Assert.That((actionResult as OkNegotiatedContentResult <TemplateViewModel>).Content.Level.Description, Is.EqualTo(string.Empty));
            Assert.That((actionResult as OkNegotiatedContentResult <TemplateViewModel>).Content.CompetencyName, Is.EqualTo(selectedCompetency.Name));
            Assert.That((actionResult as OkNegotiatedContentResult <TemplateViewModel>).Content.DomainName, Is.EqualTo("Azure Development"));
        }
Ejemplo n.º 12
0
 public int Add(JobFunction entity)
 {
     _context.SbAdd(entity);
     return(_context.SaveChanges());
 }
Ejemplo n.º 13
0
        public async Task <IActionResult> Update([FromBody] JobFunction model)
        {
            bool result = await m_JobFunctionBusiness.Update(model);

            return(Json(result));
        }
Ejemplo n.º 14
0
        public async Task <IActionResult> Create([FromBody] JobFunction model)
        {
            JobFunction JobFunction = await m_JobFunctionBusiness.Create(model);

            return(Json(JobFunction));
        }
Ejemplo n.º 15
0
 /// <summary>
 /// Constructor that accepts values for all mandatory fields
 /// </summary>
 ///<param name="schoolInfoRefId">References SchoolInfo object to determine school in which this assignment pertains.</param>
 ///<param name="gradeLevels">A GradeLevels</param>
 ///<param name="jobFunction">A JobFunction</param>
 ///
 public EmplAssignment(string schoolInfoRefId, GradeLevels gradeLevels, JobFunction jobFunction) : base(ProfdevDTD.EMPLASSIGNMENT)
 {
     this.SchoolInfoRefId = schoolInfoRefId;
     this.GradeLevels     = gradeLevels;
     this.JobFunction     = jobFunction;
 }
Ejemplo n.º 16
0
 public int Edit(JobFunction entity)
 {
     _context.SbEdit(entity);
     return(_context.SaveChanges());
 }
Ejemplo n.º 17
0
 public async Task <bool> Update(JobFunction JobFunction)
 {
     return(await m_JobFunctionRepositoryM.Update(JobFunction));
 }
        public void When_ThenFindCompetencyIsCalledOnceAndViewModelHasExpectedValues()
        {
            // Arrange
            Competency selectedCompetency = null;

            string templateId = "B7F16780-227C-46FC-A7A1-7AADF91BBECA";

            var savedTemplate = new Template
            {
                Id               = "B7F16780-227C-46FC-A7A1-7AADF91BBECA",
                CompetencyId     = 13,
                JobFunctionLevel = 3,
                Skills           = new List <SkillTemplate> {
                    new SkillTemplate
                    {
                        SkillId = 228, Questions = new List <string>()
                    },
                    new SkillTemplate
                    {
                        SkillId = 289, Questions = new List <string>()
                    }
                },
                Exercises = new List <string>()
            };

            var savedJobFunction = new JobFunction
            {
                Id           = 15,
                MnemonicBase = "D",
                Track        = 0,
                Name         = "Software Engineering"
            };

            var savedJobLevels = new List <Level>
            {
                new Level {
                    Id = 1, IsEligibleForAsmt = false, JobTitles = new List <string> {
                        "Junior Software Engineer"
                    }
                },
                new Level {
                    Id = 2, IsEligibleForAsmt = false, JobTitles = new List <string> {
                        "Software Engineer"
                    }
                },
                new Level {
                    Id = 3, IsEligibleForAsmt = true, JobTitles = new List <string> {
                        "Senior Software Engineer"
                    }
                }
            };

            var savedJobFunctionDocument = new JobFunctionDocument
            {
                Id          = "B63BE6A3-64E3-43D9-A200-4577ADFE26E5",
                JobFunction = savedJobFunction,
                Levels      = savedJobLevels
            };

            var savedCompetencies = new List <Competency>
            {
                new Competency {
                    Id = 1, Code = "DotNET", ParentId = null, IsSelectable = false, JobFunctions = new List <int>(), Name = ".NET"
                },
                new Competency {
                    Id = 13, Code = "DotNET-Azure", ParentId = 1, IsSelectable = true, JobFunctions = new List <int>(), Name = "Azure Development"
                }
            };

            var savedTopicsForSelecetedSkill = new List <Topic>
            {
                new Topic {
                    IsRequired = false, Name = "NET"
                }
            };

            var savedSkills = new List <Skill>
            {
                new Skill
                {
                    RootId           = 1001, DisplayOrder = 1, RequiredSkillLevel = 1, UserSkillLevel = 10, LevelsSet = 1, CompetencyId = 13,
                    JobFunctionLevel = 1, Topics = null, Id = 1001, ParentId = 1982, Name = "Documentation", IsSelectable = true
                },
                new Skill
                {
                    RootId           = 1001, DisplayOrder = 1, RequiredSkillLevel = 1, UserSkillLevel = 10, LevelsSet = 1, CompetencyId = 13,
                    JobFunctionLevel = 2, Topics = null, Id = 7456, ParentId = 1982, Name = "Design Patterns", IsSelectable = true
                },
                new Skill
                {
                    RootId           = 1001, DisplayOrder = 1, RequiredSkillLevel = 1, UserSkillLevel = 10, LevelsSet = 1, CompetencyId = 13,
                    JobFunctionLevel = 3, Topics = savedTopicsForSelecetedSkill, Id = 228, ParentId = 1982, Name = "NET Best Practices",
                    IsSelectable     = true
                },
                new Skill
                {
                    RootId           = 1001, DisplayOrder = 1, RequiredSkillLevel = 1, UserSkillLevel = 10, LevelsSet = 1, CompetencyId = 13,
                    JobFunctionLevel = 1, Topics = null, Id = 46, ParentId = 1982, Name = "Solid principles", IsSelectable = true
                },
                new Skill
                {
                    RootId           = 1001, DisplayOrder = 1, RequiredSkillLevel = 1, UserSkillLevel = 10, LevelsSet = 1, CompetencyId = 13,
                    JobFunctionLevel = 2, Topics = null, Id = 965, ParentId = 1982, Name = "Parallel programming", IsSelectable = true
                }
            };

            var queryJobFunction = new Mock <IJobFunctionQueryRepository>();

            queryJobFunction
            .Setup(method => method.FindJobTitleByLevel(It.IsAny <int>(), It.IsAny <int>()))
            .ReturnsAsync((int jobFunctionId, int jobFunctionLevel) => savedJobFunctionDocument.Levels.Where(item => item.Id == jobFunctionLevel).First().JobTitles.FirstOrDefault());

            var querySkillMatrix = new Mock <ISkillMatrixQueryRepository>();

            querySkillMatrix
            .Setup(method => method.FindWithinSkills(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <int[]>()))
            .ReturnsAsync((int competencyId, int jobFunctionLevel, int[] skillIds) =>
            {
                var filteredSkills = new List <Skill>();
                foreach (var skillId in skillIds)
                {
                    filteredSkills.AddRange(savedSkills.Where(item => item.CompetencyId == competencyId && item.JobFunctionLevel == jobFunctionLevel && item.Id == skillId));
                }

                return(filteredSkills);
            });

            var queryCompetency = new Mock <ICompetencyQueryRepository>();

            queryCompetency
            .Setup(method => method.FindCompetency(It.IsAny <int>()))
            .ReturnsAsync((int competencyId) =>
            {
                selectedCompetency = savedCompetencies.Where(item => item.Id == competencyId).FirstOrDefault();
                return(selectedCompetency);
            });

            var queryTemplate = new Mock <IQueryRepository <Template, string> >();

            queryTemplate
            .Setup(method => method.FindById(It.IsAny <string>()))
            .ReturnsAsync(savedTemplate);

            var queryQuestion = new Mock <IQuestionQueryRepository>();
            var queryExercise = new Mock <IExerciseQueryRepository>();

            var controllerUnderTest = new QueryTemplateController(querySkillMatrix.Object, queryTemplate.Object, queryJobFunction.Object, queryCompetency.Object, queryQuestion.Object, queryExercise.Object);

            // Act
            var actionResult = controllerUnderTest.Get(templateId).Result;

            // Assert
            Assert.That(actionResult, Is.Not.Null);
            Assert.That(actionResult, Is.TypeOf <OkNegotiatedContentResult <TemplateViewModel> >());
            Assert.That((actionResult as OkNegotiatedContentResult <TemplateViewModel>).Content.CompetencyId, Is.EqualTo(13));
            Assert.That((actionResult as OkNegotiatedContentResult <TemplateViewModel>).Content.JobFunctionLevel, Is.EqualTo(3));
            Assert.That((actionResult as OkNegotiatedContentResult <TemplateViewModel>).Content.Level.Id, Is.EqualTo(3));
            Assert.That((actionResult as OkNegotiatedContentResult <TemplateViewModel>).Content.Level.Description, Is.EqualTo(string.Empty));
            Assert.That((actionResult as OkNegotiatedContentResult <TemplateViewModel>).Content.Level.Name, Is.EqualTo("L3"));
            Assert.That((actionResult as OkNegotiatedContentResult <TemplateViewModel>).Content.CompetencyName, Is.EqualTo(selectedCompetency.Name));
            Assert.That((actionResult as OkNegotiatedContentResult <TemplateViewModel>).Content.DomainName, Is.EqualTo("Azure Development"));
            Assert.That((actionResult as OkNegotiatedContentResult <TemplateViewModel>).Content.Skills.Count, Is.EqualTo(1));
            Assert.That((actionResult as OkNegotiatedContentResult <TemplateViewModel>).Content.Skills.First().RootId, Is.EqualTo(1001));
            Assert.That((actionResult as OkNegotiatedContentResult <TemplateViewModel>).Content.Skills.First().DisplayOrder, Is.EqualTo(1));
            Assert.That((actionResult as OkNegotiatedContentResult <TemplateViewModel>).Content.Skills.First().RequiredSkillLevel, Is.EqualTo(1));
            Assert.That((actionResult as OkNegotiatedContentResult <TemplateViewModel>).Content.Skills.First().UserSkillLevel, Is.EqualTo(10));
            Assert.That((actionResult as OkNegotiatedContentResult <TemplateViewModel>).Content.Skills.First().LevelsSet, Is.EqualTo(1));
            Assert.That((actionResult as OkNegotiatedContentResult <TemplateViewModel>).Content.Skills.First().CompetencyId, Is.EqualTo(13));
            Assert.That((actionResult as OkNegotiatedContentResult <TemplateViewModel>).Content.Skills.First().JobFunctionLevel, Is.EqualTo(3));
            Assert.That((actionResult as OkNegotiatedContentResult <TemplateViewModel>).Content.Skills.First().Topics.Count(), Is.EqualTo(1));
            Assert.That((actionResult as OkNegotiatedContentResult <TemplateViewModel>).Content.Skills.First().Topics.First().IsRequired, Is.EqualTo(false));
            Assert.That((actionResult as OkNegotiatedContentResult <TemplateViewModel>).Content.Skills.First().Topics.First().Name, Is.EqualTo("NET"));
            Assert.That((actionResult as OkNegotiatedContentResult <TemplateViewModel>).Content.Skills.First().Questions, Is.Empty);
            Assert.That((actionResult as OkNegotiatedContentResult <TemplateViewModel>).Content.Skills.First().Id, Is.EqualTo(228));
            Assert.That((actionResult as OkNegotiatedContentResult <TemplateViewModel>).Content.Skills.First().ParentId, Is.EqualTo(1982));
            Assert.That((actionResult as OkNegotiatedContentResult <TemplateViewModel>).Content.Skills.First().Name, Is.EqualTo("NET Best Practices"));
            Assert.That((actionResult as OkNegotiatedContentResult <TemplateViewModel>).Content.Skills.First().IsSelectable, Is.EqualTo(true));
            Assert.That((actionResult as OkNegotiatedContentResult <TemplateViewModel>).Content.Exercises, Is.Empty);
        }