/// <summary>
        /// Initial Summary Evaluation Detail ViewModel.
        /// </summary>
        /// <param name="item">The summary evaluation detail viewmodel.</param>
        /// <param name="score">The score.</param>
        /// <returns></returns>
        private SummaryEvaluationDetailViewModel InitialModel(SummaryEvaluationDetailViewModel item, double score,
                                                              EvaluationPercentageConfig percentageConfig, string weightingKey, int userCount,
                                                              IEnumerable <SummaryEvaluationDetailViewModel> userResult = null,
                                                              string fromUser = "")
        {
            double totalScore = 0;

            if (!string.Equals(weightingKey, "A2", StringComparison.OrdinalIgnoreCase))
            {
                totalScore = Math.Round(UtilityService.AverageScore((item.Score + score), userCount));
            }
            else
            {
                int[] percentage = new int[] { percentageConfig.PurchasePercentage, percentageConfig.UserPercentage };
                if (userResult == null || userResult.Count() == 0)
                {
                    percentage[0] = 100; //purchase percentage calculate 100 percen when no user evaluation
                    percentage[1] = 0;   //user percentage
                }
                totalScore = UtilityService.CalculateScore(item.Score, score, percentage[1], percentage[0], weightingKey);
            }
            return(new SummaryEvaluationDetailViewModel
            {
                KpiGroupId = item.KpiGroupId,
                KpiId = item.KpiId.HasValue ? item.KpiId : 0,
                Score = totalScore,
                Sequence = item.Sequence
            });
        }
示例#2
0
        /// <summary>
        /// Insert new Evaluation Percentage Config.
        /// </summary>
        /// <param name="model">The Evaluation Percentage Config information value.</param>
        /// <returns></returns>
        public ResultViewModel Save(EvaluationPercentageConfigRequestModel model)
        {
            var result = new ResultViewModel();

            using (TransactionScope scope = new TransactionScope())
            {
                var evaConfig = new EvaluationPercentageConfig
                {
                    UserPercentage     = model.UserPercentage,
                    PurchasePercentage = model.PurchasePercentage,
                    StartDate          = DateTime.Now.Date,
                    CreateBy           = _token.EmpNo,
                    CreateDate         = DateTime.Now
                };
                var configs = _unitOfWork.GetRepository <EvaluationPercentageConfig>().GetCache();
                configs.Select(c => { c.EndDate = DateTime.Now.Date.AddDays(-1); return(c); }).ToList();
                _unitOfWork.GetRepository <EvaluationPercentageConfig>().Add(evaConfig);
                _unitOfWork.GetRepository <EvaluationPercentageConfig>().UpdateRange(configs);
                _unitOfWork.Complete(scope);
            }
            this.ReloadCacheEvaluationPercentageConfig();
            return(result);
        }