Пример #1
0
        public IActionResult AppraisalTemplate(string id)
        {
            var orgId = getOrg();

            var  idsplit = id.Split(',');
            Guid ids     = Guid.Parse(idsplit[0]);
            Guid appId   = Guid.Parse(idsplit[1]);

            AppraisalViewTemplateViewModel avtVM = new AppraisalViewTemplateViewModel();

            List <AppCat>       appCat = new List <AppCat>();
            List <AppraisalKPI> kPIs;
            AppCat sAppCat;

            List <Guid> kpiId = new List <Guid>();

            var temp    = _context.AppraisalTemplates.Where(x => x.Id == ids).FirstOrDefault();
            var appCats = _context.AppraisalTemplateCategories.Where(x => x.AppraisalTemplateId == ids).Include(x => x.AppraisalCategory).ToList();
            var kpi     = _context.AppraisalKPIs.Where(x => x.OrganisationId == orgId);

            avtVM.TemplateName = temp.Template;


            AppraisalCategoryEdit ace;

            foreach (var item in appCats)
            {
                sAppCat = new AppCat();
                ace     = new AppraisalCategoryEdit();
                kPIs    = new List <AppraisalKPI>();

                sAppCat.AppraisalTemplateCategory = item;
                ace.AppraisalCategory             = item.AppraisalCategory;
                kPIs = kpi.Where(x => x.AppraisalCategoryId == item.AppraisalCategoryId).ToList();

                kpiId.AddRange(kPIs.Select(x => x.Id));

                ace.AppraisalKPIs             = kPIs;
                sAppCat.AppraisalCategoryEdit = ace;

                appCat.Add(sAppCat);
            }

            avtVM.AppCat   = appCat;
            avtVM.kpiId    = kpiId;
            avtVM.AppTemId = appId;
            return(View(avtVM));
        }
        public IActionResult ViewTemplate(Guid id)
        {
            var orgId = getOrg();

            AppraisalViewTemplateViewModel avtVM = new AppraisalViewTemplateViewModel();

            List <AppCat>       appCat = new List <AppCat>();
            List <AppraisalKPI> kPIs;
            AppCat sAppCat;

            var temp    = _context.AppraisalTemplates.Where(x => x.Id == id).FirstOrDefault();
            var appCats = _context.AppraisalTemplateCategories.Where(x => x.AppraisalTemplateId == id).Include(x => x.AppraisalCategory).ToList();
            var kpi     = _context.AppraisalKPIs.Where(x => x.OrganisationId == orgId);

            avtVM.TemplateName = temp.Template;


            AppraisalCategoryEdit ace;

            foreach (var item in appCats)
            {
                sAppCat = new AppCat();
                ace     = new AppraisalCategoryEdit();
                kPIs    = new List <AppraisalKPI>();

                sAppCat.AppraisalTemplateCategory = item;
                ace.AppraisalCategory             = item.AppraisalCategory;
                kPIs = kpi.Where(x => x.AppraisalCategoryId == item.AppraisalCategoryId).ToList();


                ace.AppraisalKPIs             = kPIs;
                sAppCat.AppraisalCategoryEdit = ace;

                appCat.Add(sAppCat);
            }

            avtVM.AppCat = appCat;
            return(View(avtVM));
        }