Ejemplo n.º 1
0
        private void AddIncidents()
        {
            IncidentBasicInfo incidentBasicInfo1 = new IncidentBasicInfo()
            {
                Id                = "BI1",
                Type              = IncidentType.Unplanned,
                Priority          = 3,
                Confirmed         = false,
                Status            = IncidentStatus.Draft,
                ETA               = DateTime.Now.AddDays(-5),
                ATA               = DateTime.Now,
                OutageTime        = DateTime.Now.AddDays(-7),
                ETR               = DateTime.Now.AddDays(1),
                AffectedCustomers = 13,
                Voltage           = 0.22,
                ScheduledTime     = DateTime.Now.AddDays(1),
                SelfAssigned      = false,
            };

            IncidentBasicInfo incidentBasicInfo2 = new IncidentBasicInfo()
            {
                Id                = "BI2",
                Type              = IncidentType.Planned,
                Priority          = 28,
                Confirmed         = true,
                Status            = IncidentStatus.Cancelled,
                ETA               = DateTime.Now.AddDays(-5),
                ATA               = DateTime.Now,
                OutageTime        = DateTime.Now.AddDays(-7),
                ETR               = DateTime.Now.AddDays(1),
                AffectedCustomers = 10,
                Voltage           = 0.14,
                ScheduledTime     = DateTime.Now.AddDays(1),
                SelfAssigned      = false,
            };

            Incident incident1 = new Incident()
            {
                BasicInfo = incidentBasicInfo1,
                Id        = "I1",
            };

            Incident incident2 = new Incident()
            {
                BasicInfo = incidentBasicInfo2,
                Id        = "I2",
            };

            this.IncidentBasicInfoes.Add(incidentBasicInfo1);
            this.IncidentBasicInfoes.Add(incidentBasicInfo2);

            this.Incidents.Add(incident1);
            this.Incidents.Add(incident2);

            this.SaveChanges();
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> AddIncident(string id, double voltage, string scheduledTime, int affectedCustomers, string ata,
                                                      string eta, string etr, bool confirmed, bool selfAssigned, string incidentStatus, string outageTime,
                                                      string incidentType, string cause, string subcause, string material, string constructionType)
        {
            IncidentBasicInfo basicInfo = new IncidentBasicInfo()
            {
                Id                = "Binfo_" + id,
                Voltage           = voltage,
                ScheduledTime     = DateTime.Parse(scheduledTime),
                AffectedCustomers = affectedCustomers,
                ATA               = DateTime.Parse(ata),
                ETA               = DateTime.Parse(eta),
                ETR               = DateTime.Parse(etr),
                Confirmed         = confirmed,
                SelfAssigned      = selfAssigned,
                Status            = (IncidentStatus)Enum.Parse(typeof(IncidentStatus), incidentStatus),
                OutageTime        = DateTime.Parse(outageTime),
                Priority          = 0,
                Type              = (IncidentType)Enum.Parse(typeof(IncidentType), incidentType),
            };


            Incident incident = new Incident()
            {
                BasicInfoId      = "Binfo_" + id,
                Id               = id,
                Cause            = cause,
                Subcause         = subcause,
                Material         = material,
                ConstructionType = constructionType,
            };


            _context.IncidentBasicInfoes.Add(basicInfo);
            _context.Incidents.Add(incident);
            await _context.SaveChangesAsync();

            return(Ok());
        }