Exemple #1
0
        public JsonResult GetOperationData(int id)
        {
            var skillMatrices = _context.SkillMatrixs
                                .Include(s => s.Operation)
                                .Include(s => s.Operator)
                                .Where(s => s.OperationId == id)
                                .ToList();
            List <OperationSkillMatrixViewModel> operatorInfoSkillMatrixViewModels = new List <OperationSkillMatrixViewModel>();

            if (skillMatrices.Count != 0)
            {
                foreach (var skillMatrix in skillMatrices)
                {
                    OperationSkillMatrixViewModel operatorInfoSkillMatrixViewModel = new OperationSkillMatrixViewModel();

                    double rowTotalSot50 = Math.Round((skillMatrix.StandardSotInSecond / skillMatrix.SotScore) * 50, 2);
                    double rowTotalRft50 = Math.Round((skillMatrix.RftScore * 50 / skillMatrix.StandardRft), 2);
                    double rowTotal100   = rowTotalSot50 + rowTotalRft50;
                    if (rowTotal100 < 0)
                    {
                        rowTotal100 = 0;
                    }
                    string grade = GetGrade(rowTotal100);

                    operatorInfoSkillMatrixViewModel.OperatorName         = skillMatrix.Operator.Name;
                    operatorInfoSkillMatrixViewModel.OperatorIdCardNumber = skillMatrix.Operator.IdCardNumber;
                    operatorInfoSkillMatrixViewModel.Score = rowTotal100;
                    operatorInfoSkillMatrixViewModel.Grade = grade;
                    operatorInfoSkillMatrixViewModels.Add(operatorInfoSkillMatrixViewModel);
                }
            }

            return(new JsonResult(operatorInfoSkillMatrixViewModels));
        }
Exemple #2
0
        public JsonResult GetOperationDataById(string data)
        {
            var searchOperationByLineIdViewModel = JsonConvert.DeserializeObject <SearchOperationByLineIdViewModel>(data);

            if (searchOperationByLineIdViewModel.OperationId == null || searchOperationByLineIdViewModel.OperatorId == null)
            {
                return(new JsonResult(false));
            }
            var skillMatrices = _context.SkillMatrixs
                                .Include(s => s.Operation)
                                .Include(s => s.Operator)
                                .Where(s => s.OperationId == searchOperationByLineIdViewModel.OperationId)
                                .ToList();
            List <OperationSkillMatrixViewModel> operatorInfoSkillMatrixViewModels      = new List <OperationSkillMatrixViewModel>();
            List <OperationSkillMatrixViewModel> FoundOperatorInfoSkillMatrixViewModels = new List <OperationSkillMatrixViewModel>();

            if (skillMatrices == null)
            {
                return(new JsonResult(false));
            }
            if (skillMatrices.Count != 0)
            {
                foreach (var skillMatrix in skillMatrices)
                {
                    if (searchOperationByLineIdViewModel.OperatorId.Exists(m => m == skillMatrix.OperatorId))
                    {
                        OperationSkillMatrixViewModel operatorInfoSkillMatrixViewModel = new OperationSkillMatrixViewModel();

                        double rowTotalSot50 = Math.Round((skillMatrix.StandardSotInSecond / skillMatrix.SotScore) * 50, 2);
                        double rowTotalRft50 = Math.Round((skillMatrix.RftScore * 50 / skillMatrix.StandardRft), 2);
                        double rowTotal100   = rowTotalSot50 + rowTotalRft50;
                        if (rowTotal100 < 0)
                        {
                            rowTotal100 = 0;
                        }
                        string grade = GetGrade(rowTotal100);

                        operatorInfoSkillMatrixViewModel.OperatorName         = skillMatrix.Operator.Name;
                        operatorInfoSkillMatrixViewModel.OperatorIdCardNumber = skillMatrix.Operator.IdCardNumber;
                        operatorInfoSkillMatrixViewModel.Score = rowTotal100;
                        operatorInfoSkillMatrixViewModel.Grade = grade;
                        operatorInfoSkillMatrixViewModels.Add(operatorInfoSkillMatrixViewModel);
                    }
                }
            }

            return(new JsonResult(operatorInfoSkillMatrixViewModels));
        }