Ejemplo n.º 1
0
 public void DeleteIndicatorGroup(IndicatorGroup indicatorGroup)
 {
     for (int i = 0; i < indicatorGroup.Indicators.Count; i++)
     {
         indicatorGroup.Indicators.Remove(indicatorGroup.Indicators[i]);
         i--;
     }
     _indicatorGroupRepository.Delete(indicatorGroup);
     SaveIndicator();
 }
        public string[] GetIndicatorsNames(IndicatorGroup indicatorsGroup)
        {
            lock (this)
            {
                if (_indicatorsGroups.ContainsKey(indicatorsGroup))
                {
                    return(GeneralHelper.EnumerableToArray <string>(_indicatorsGroups[indicatorsGroup].Keys));
                }
            }

            return(new string [] { });
        }
        /// <summary>
        ///
        /// </summary>
        public PlatformIndicator GetIndicatorCloneByName(IndicatorGroup indicatorGroup, string name)
        {
            lock (this)
            {
                if (_indicatorsGroups[indicatorGroup].ContainsKey(name))
                {
                    return(((PlatformIndicator)_indicatorsGroups[indicatorGroup][name]).SimpleClone());
                }
            }

            return(null);
        }
Ejemplo n.º 4
0
        public ActionResult DeleteConfirmed(int id)
        {
            IndicatorGroup indicatorGroup  = db.IndicatorGroups.Find(id);
            IndicatorGroup _indicatorGroup = new IndicatorGroup()
            {
                ID = id, Name = indicatorGroup.Name
            };

            db.IndicatorGroups.Remove(indicatorGroup);
            db.SaveChanges();
            Log(LogAction.Delete, _indicatorGroup);
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 5
0
        // GET: IndicatorGroups/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            IndicatorGroup indicatorGroup = db.IndicatorGroups.Find(id);

            if (indicatorGroup == null)
            {
                return(HttpNotFound());
            }
            return(View(indicatorGroup));
        }
Ejemplo n.º 6
0
        // GET: IndicatorGroups/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            IndicatorGroup indicatorGroup = db.IndicatorGroups.Include(x => x.Indicators).Where(x => x.ID == id).FirstOrDefault();

            if (indicatorGroup == null)
            {
                return(HttpNotFound());
            }
            ViewBag.Indicators   = db.Indicators.ToDictionary(x => x.ID, x => x.Name);
            ViewBag.indicatorIds = indicatorGroup.Indicators.Select(x => x.ID).ToArray();
            return(View(indicatorGroup));
        }
        public string[] GetIndicatorsDescriptions(IndicatorGroup indicatorsGroup)
        {
            lock (this)
            {
                if (_indicatorsGroups.ContainsKey(indicatorsGroup) == false)
                {
                    return(new string[] { });
                }

                string[] result = new string[_indicatorsGroups[indicatorsGroup].Count];
                int      i      = 0;
                foreach (string name in _indicatorsGroups[indicatorsGroup].Keys)
                {
                    result[i] = _indicatorsGroups[indicatorsGroup][name].Description;
                    i++;
                }
                return(result);
            }
        }
Ejemplo n.º 8
0
        public ActionResult Create([Bind(Include = "ID,Code,Name,Description")] IndicatorGroup indicatorGroup, int[] indicatorIds)
        {
            if (ModelState.IsValid)
            {
                var indicators = db.Indicators.Where(x => indicatorIds.Contains(x.ID));
                foreach (var i in indicators)
                {
                    indicatorGroup.Indicators.Add(i);
                }

                db.IndicatorGroups.Add(indicatorGroup);
                db.SaveChanges();
                Log(LogAction.Create, indicatorGroup);
                return(RedirectToAction("Index"));
            }

            ViewBag.Indicators   = db.Indicators.ToDictionary(x => x.ID, x => x.Name);
            ViewBag.indicatorIds = indicatorIds;
            return(View(indicatorGroup));
        }
        public async Task <IActionResult> PostIndicatorGroup([FromBody] IndicatorGroup indicatorGroup)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            List <IndicatorGroup> indicatorGroups = _context.IndicatorGroups.ToList();;

            foreach (IndicatorGroup ig in indicatorGroups)
            {
                if (ig.Name.ToUpper().Trim().Equals(indicatorGroup.Name.ToUpper().Trim()) && ig.IndicatorGroupID != indicatorGroup.IndicatorGroupID)
                {
                    return(Json(false));
                }
            }

            _context.IndicatorGroups.Add(indicatorGroup);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetIndicatorGroup", new { id = indicatorGroup.IndicatorGroupID }, indicatorGroup));
        }
Ejemplo n.º 10
0
        public ActionResult Edit([Bind(Include = "ID,Code,Name,Description")] IndicatorGroup indicatorGroup, int[] indicatorIds)
        {
            if (ModelState.IsValid)
            {
                db.Entry(indicatorGroup).State = EntityState.Modified;
                var ig = db.IndicatorGroups.Include(x => x.Indicators).Where(x => x.ID == indicatorGroup.ID).FirstOrDefault();
                indicatorGroup.Indicators = ig.Indicators;
                indicatorGroup.Indicators.Clear();
                var indicators = db.Indicators.Where(x => indicatorIds.Contains(x.ID));
                foreach (var i in indicators)
                {
                    indicatorGroup.Indicators.Add(i);
                }

                db.SaveChanges();
                Log(LogAction.Update, indicatorGroup);
                return(RedirectToAction("Index"));
            }
            ViewBag.Indicators   = db.Indicators.ToDictionary(x => x.ID, x => x.Name);
            ViewBag.indicatorIds = indicatorIds;
            return(View(indicatorGroup));
        }
Ejemplo n.º 11
0
        public async Task <IActionResult> PutIndicatorGroup([FromRoute] long id, [FromBody] IndicatorGroup indicatorGroup)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            List <IndicatorGroup> indicatorGroups = await _context.IndicatorGroups.Where(ig => ig.Name == indicatorGroup.Name && ig.IndicatorGroupID != id).ToListAsync();

            if (indicatorGroups.Any())
            {
                return(NoContent());
            }

            if (id != indicatorGroup.IndicatorGroupID)
            {
                return(BadRequest());
            }

            _context.Entry(indicatorGroup).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!IndicatorGroupExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Ok(indicatorGroup));
        }
Ejemplo n.º 12
0
 public void EditIndicatorGroup(IndicatorGroup indicatorGroup)
 {
     indicatorGroup.DateChanged = DateTime.Now;
     _indicatorGroupRepository.Update(indicatorGroup);
     SaveIndicator();
 }
        public string[] GetIndicatorsDescriptions(IndicatorGroup indicatorsGroup)
        {
            lock (this)
            {
                if (_indicatorsGroups.ContainsKey(indicatorsGroup) == false)
                {
                    return new string[] { };
                }

                string[] result = new string[_indicatorsGroups[indicatorsGroup].Count];
                int i = 0;
                foreach(string name in _indicatorsGroups[indicatorsGroup].Keys)
                {
                    result[i] = _indicatorsGroups[indicatorsGroup][name].Description;
                    i++;
                }
                return result;
            }
        }
Ejemplo n.º 14
0
 public void CreateIndicatorGroup(IndicatorGroup indicatorGroup)
 {
     _indicatorGroupRepository.Add(indicatorGroup);
     SaveIndicator();
 }
        public async Task Get()
        {
            var release = new Release();

            var subject1 = new Subject
            {
                Filename = "file1.csv",
                Name     = "Subject 1"
            };

            var subject2 = new Subject
            {
                Filename = "file2.csv",
                Name     = "Subject 2"
            };

            var subject1Filter = new Filter
            {
                Subject = subject1,
                Name    = "subject1_filter",
                Label   = "Subject 1 Filter",
                Hint    = "Hint"
            };

            var subject2Filter = new Filter
            {
                Subject = subject2,
                Name    = "subject2_filter",
                Label   = "Subject 2 Filter",
                Hint    = null
            };

            var subject1IndicatorGroup = new IndicatorGroup
            {
                Subject    = subject1,
                Indicators = new List <Indicator>
                {
                    new Indicator
                    {
                        Name  = "subject1_indicator",
                        Label = "Subject 1 Indicator"
                    }
                }
            };

            var subject2IndicatorGroup = new IndicatorGroup
            {
                Subject    = subject2,
                Indicators = new List <Indicator>
                {
                    new Indicator
                    {
                        Name  = "subject2_indicator",
                        Label = "Subject 2 Indicator"
                    }
                }
            };

            var releaseSubject1 = new ReleaseSubject
            {
                Release      = release,
                Subject      = subject1,
                MetaGuidance = "Subject 1 Meta Guidance"
            };

            var releaseSubject2 = new ReleaseSubject
            {
                Release      = release,
                Subject      = subject2,
                MetaGuidance = "Subject 2 Meta Guidance"
            };

            var subject1Observation1 = new Observation
            {
                GeographicLevel = GeographicLevel.Country,
                Subject         = subject1,
                Year            = 2020,
                TimeIdentifier  = TimeIdentifier.AcademicYearQ3
            };

            var subject1Observation2 = new Observation
            {
                GeographicLevel = GeographicLevel.LocalAuthority,
                Subject         = subject1,
                Year            = 2020,
                TimeIdentifier  = TimeIdentifier.AcademicYearQ4
            };

            var subject1Observation3 = new Observation
            {
                GeographicLevel = GeographicLevel.LocalAuthorityDistrict,
                Subject         = subject1,
                Year            = 2021,
                TimeIdentifier  = TimeIdentifier.AcademicYearQ1
            };

            var subject2Observation1 = new Observation
            {
                GeographicLevel = GeographicLevel.Country,
                Subject         = subject2,
                Year            = 2020,
                TimeIdentifier  = TimeIdentifier.SummerTerm
            };

            var subject2Observation2 = new Observation
            {
                GeographicLevel = GeographicLevel.Region,
                Subject         = subject2,
                Year            = 2021,
                TimeIdentifier  = TimeIdentifier.AutumnTerm
            };

            var subject2Observation3 = new Observation
            {
                GeographicLevel = GeographicLevel.Region,
                Subject         = subject2,
                Year            = 2021,
                TimeIdentifier  = TimeIdentifier.SpringTerm
            };

            var statisticsDbContextId = Guid.NewGuid().ToString();

            await using (var statisticsDbContext = InMemoryStatisticsDbContext(statisticsDbContextId))
            {
                await statisticsDbContext.AddAsync(release);

                await statisticsDbContext.AddRangeAsync(subject1, subject2);

                await statisticsDbContext.AddRangeAsync(releaseSubject1, releaseSubject2);

                await statisticsDbContext.AddRangeAsync(subject1Filter, subject2Filter);

                await statisticsDbContext.AddRangeAsync(subject1IndicatorGroup, subject2IndicatorGroup);

                await statisticsDbContext.AddRangeAsync(subject1Observation1, subject1Observation2,
                                                        subject1Observation3, subject2Observation1, subject2Observation2, subject2Observation3);

                await statisticsDbContext.SaveChangesAsync();
            }

            await using (var statisticsDbContext = InMemoryStatisticsDbContext(statisticsDbContextId))
            {
                var service = SetupMetaGuidanceSubjectService(context: statisticsDbContext);

                var result = await service.GetSubjects(release.Id);

                // Assert there are two Subjects with the correct content
                Assert.True(result.IsRight);

                Assert.Equal(2, result.Right.Count);

                Assert.Equal(subject1.Id, result.Right[0].Id);
                Assert.Equal("Subject 1 Meta Guidance", result.Right[0].Content);
                Assert.Equal("file1.csv", result.Right[0].Filename);
                Assert.Equal("Subject 1", result.Right[0].Name);
                Assert.Equal("2020/21 Q3", result.Right[0].TimePeriods.From);
                Assert.Equal("2021/22 Q1", result.Right[0].TimePeriods.To);
                Assert.Equal(new List <string>
                {
                    "National", "Local Authority", "Local Authority District"
                }, result.Right[0].GeographicLevels);
                Assert.Equal(2, result.Right[0].Variables.Count);
                Assert.Equal("Subject 1 Filter - Hint", result.Right[0].Variables[0].Label);
                Assert.Equal("subject1_filter", result.Right[0].Variables[0].Value);
                Assert.Equal("Subject 1 Indicator", result.Right[0].Variables[1].Label);
                Assert.Equal("subject1_indicator", result.Right[0].Variables[1].Value);

                Assert.Equal(subject2.Id, result.Right[1].Id);
                Assert.Equal("Subject 2 Meta Guidance", result.Right[1].Content);
                Assert.Equal("file2.csv", result.Right[1].Filename);
                Assert.Equal("Subject 2", result.Right[1].Name);
                Assert.Equal("2020/21 Summer Term", result.Right[1].TimePeriods.From);
                Assert.Equal("2021/22 Spring Term", result.Right[1].TimePeriods.To);
                Assert.Equal(new List <string>
                {
                    "National", "Regional"
                }, result.Right[1].GeographicLevels);
                Assert.Equal(2, result.Right[1].Variables.Count);
                Assert.Equal("Subject 2 Filter", result.Right[1].Variables[0].Label);
                Assert.Equal("subject2_filter", result.Right[1].Variables[0].Value);
                Assert.Equal("Subject 2 Indicator", result.Right[1].Variables[1].Label);
                Assert.Equal("subject2_indicator", result.Right[1].Variables[1].Value);
            }
        }
Ejemplo n.º 16
0
        public static void Initialize(DataContext context)
        {
            context.Database.EnsureCreated();

            // Look for any indicator group.
            if (context.IndicatorGroups.Any())
            {
                return;   // DB has been seeded
            }

            DbInitializer.roles = CreateRoles(context);

            var IndicatorGroup1 = new IndicatorGroup {
                Name = "Estimación de aumento de inversiones de las empresas"
            };

            context.IndicatorGroups.Add(IndicatorGroup1);
            context.SaveChanges();
            CreateIndicatorsGroup1(context, IndicatorGroup1.IndicatorGroupID);

            var IndicatorGroup2 = new IndicatorGroup {
                Name = "Estimación de la creación de nuevos empleos a partir de la prestación de servicios"
            };

            context.IndicatorGroups.Add(IndicatorGroup2);
            context.SaveChanges();
            CreateIndicatorsGroup2(context, IndicatorGroup2.IndicatorGroupID);

            var IndicatorGroup3 = new IndicatorGroup {
                Name = "Estimación de la disminución de costos en empresas"
            };

            context.IndicatorGroups.Add(IndicatorGroup3);
            context.SaveChanges();
            CreateIndicatorsGroup3(context, IndicatorGroup3.IndicatorGroupID);

            var IndicatorGroup4 = new IndicatorGroup {
                Name = "Estimación del aumento de ventas en empresas"
            };

            context.IndicatorGroups.Add(IndicatorGroup4);
            context.SaveChanges();
            CreateIndicatorsGroup4(context, IndicatorGroup4.IndicatorGroupID);

            var IndicatorGroup5 = new IndicatorGroup {
                Name = "Estimación del aumento de productividad en empresas"
            };

            context.IndicatorGroups.Add(IndicatorGroup5);
            context.SaveChanges();
            CreateIndicatorsGroup5(context, IndicatorGroup5.IndicatorGroupID);

            var IndicatorGroup6 = new IndicatorGroup {
                Name = "Satisfacción de empresas por servicios prestados"
            };

            context.IndicatorGroups.Add(IndicatorGroup6);
            context.SaveChanges();
            CreateIndicatorsGroup6(context, IndicatorGroup6.IndicatorGroupID);

            var IndicatorGroup7 = new IndicatorGroup {
                Name = "Sustentabilidad del CET"
            };

            context.IndicatorGroups.Add(IndicatorGroup7);
            context.SaveChanges();
            CreateIndicatorsGroup7(context, IndicatorGroup7.IndicatorGroupID);

            var IndicatorGroup8 = new IndicatorGroup {
                Name = "Mejora de procesos internos CET"
            };

            context.IndicatorGroups.Add(IndicatorGroup8);
            context.SaveChanges();
            CreateIndicatorsGroup8(context, IndicatorGroup8.IndicatorGroupID);

            var IndicatorGroup9 = new IndicatorGroup {
                Name = "Prestación de servicios de extensionismo tecnológico a empresas"
            };

            context.IndicatorGroups.Add(IndicatorGroup9);
            context.SaveChanges();
            CreateIndicatorsGroup9(context, IndicatorGroup9.IndicatorGroupID);

            var IndicatorGroup10 = new IndicatorGroup {
                Name = "Vinculación con entidades nacionales e internacionales"
            };

            context.IndicatorGroups.Add(IndicatorGroup10);
            context.SaveChanges();
            CreateIndicatorsGroup10(context, IndicatorGroup10.IndicatorGroupID);

            var IndicatorGroup11 = new IndicatorGroup {
                Name = "Vinculación con Académicos y Estudiantes"
            };

            context.IndicatorGroups.Add(IndicatorGroup11);
            context.SaveChanges();
            CreateIndicatorsGroup11(context, IndicatorGroup11.IndicatorGroupID);

            var IndicatorGroup12 = new IndicatorGroup {
                Name = "Cumplimiento del presupuesto del CET"
            };

            context.IndicatorGroups.Add(IndicatorGroup12);
            context.SaveChanges();
            CreateIndicatorsGroup12(context, IndicatorGroup12.IndicatorGroupID);

            var IndicatorGroup13 = new IndicatorGroup {
                Name = "Formación de los profesionales extensionistas e integrantes del equipo de gestión en ámbitos relacionados al Extensionismo tecnológico"
            };

            context.IndicatorGroups.Add(IndicatorGroup13);
            context.SaveChanges();
            CreateIndicatorsGroup13(context, IndicatorGroup13.IndicatorGroupID);
        }
        /// <summary>
        /// 
        /// </summary>
        public PlatformIndicator GetIndicatorCloneByName(IndicatorGroup indicatorGroup, string name)
        {
            lock (this)
            {
                if (_indicatorsGroups[indicatorGroup].ContainsKey(name))
                {
                    return ((PlatformIndicator)_indicatorsGroups[indicatorGroup][name]).SimpleClone();
                }
            }

            return null;
        }
        public string[] GetIndicatorsNames(IndicatorGroup indicatorsGroup)
        {
            lock (this)
            {
                if (_indicatorsGroups.ContainsKey(indicatorsGroup))
                {
                    return GeneralHelper.EnumerableToArray<string>(_indicatorsGroups[indicatorsGroup].Keys);
                }
            }

            return new string [] { };
        }