Exemplo n.º 1
0
        public async Task GetAllIncidentsAsyncShouldReturnAllIncidents()
        {
            optionsBuilder.UseInMemoryDatabase("GetAllIncidentsAsyncShouldReturnAllIncidents");
            using (var context = new DatabaseContext(optionsBuilder.Options))
            {
                context.AddRange
                (
                    new Incident {
                    Description = "Regular 'dividing by zero' incident, nothing special", Status = "Opened"
                },
                    new Incident {
                    Description = "Pug-dog rebellion", Status = "Pending"
                },
                    new Incident {
                    Description = "Grass is green", Status = "Declined"
                }
                );
                context.SaveChanges();

                IIncidentService testIncidentService = new IncidentService(context);
                var incidents = await testIncidentService.GetAllIncidentsAsync();

                incidents.ToList();

                Assert.AreEqual(3, incidents.Count());
            }
        }
Exemplo n.º 2
0
        public async Task GetSingleIncidentByExpressionAsyncShouldReturnSingleIncidentByExpressionIncidentById()
        {
            int testId = 3;
            Expression <Func <Incident, bool> > testExpression = IncidentQueries.IncidentById(testId);

            optionsBuilder.UseInMemoryDatabase("GetSingleIncidentByExpressionAsyncShouldReturnSingleIncidentByExpressionIncidentById");
            using (var context = new DatabaseContext(optionsBuilder.Options))
            {
                context.AddRange
                (
                    new Incident {
                    Description = "Regular 'dividing by zero' incident, nothing special", Status = "Opened"
                },
                    new Incident {
                    Description = "Pug-dog rebellion", Status = "Pending"
                },
                    new Incident {
                    Description = "Grass is green", Status = "Declined"
                }
                );

                IIncidentService testIncidentService = new IncidentService(context);
                var incident = await testIncidentService.GetSingleIncidentByExpressionAsync(testExpression);

                Assert.AreNotEqual(null, incident);
                Assert.AreEqual(testId, incident.IncidentId);
            }
        }
Exemplo n.º 3
0
        public async Task GetIncidentByIdAsyncShouldReturnNullIfThereNoMatchingId()
        {
            int testId = 110;

            optionsBuilder.UseInMemoryDatabase("GetIncidentByIdAsyncShouldReturnNullIfThereNoMatchingId");
            using (var context = new DatabaseContext(optionsBuilder.Options))
            {
                context.AddRange
                (
                    new Incident {
                    Description = "Regular 'dividing by zero' incident, nothing special", Status = "Opened"
                },
                    new Incident {
                    Description = "Pug-dog rebellion", Status = "Pending"
                },
                    new Incident {
                    Description = "Grass is green", Status = "Declined"
                }
                );

                IIncidentService testIncidentService = new IncidentService(context);
                var incident = await testIncidentService.GetIncidentByIdAsync(testId);

                Assert.AreEqual(null, incident);
            }
        }
Exemplo n.º 4
0
        public async Task GetAllIncidentsAsyncShouldReturnEmptyIEnumerableIfThereNoIncidents()
        {
            optionsBuilder.UseInMemoryDatabase("GetAllIncidentsAsyncShouldReturnEmptyIEnumerableIfThereNoIncidents");
            using (var context = new DatabaseContext(optionsBuilder.Options))
            {
                IIncidentService testIncidentService = new IncidentService(context);
                var incidents = await testIncidentService.GetAllIncidentsAsync();

                Assert.IsFalse(incidents.Any());
            }
        }
Exemplo n.º 5
0
 public IHttpActionResult Search(string query)
 {
     if (!string.IsNullOrEmpty(query) && query.Length > 1)
     {
         return(Ok(IncidentService.Search(query)));
     }
     else
     {
         return(Ok(new List <SimpleSearchResult>()));
     }
 }
Exemplo n.º 6
0
        private async Task LoadPropertyHistory(string id)
        {
            try
            {
                PropertyHistoryModels.Clear();
                var items = await IncidentService.GetPropertyHistory(id);

                foreach (var item in items)
                {
                    PropertyHistoryModels.Add(new PropertyHistoryModel()
                    {
                        FirstRow = string.Concat(item.firstName, " ", item.lastName) + (item.roleName.Length == 0 ? "" : ", " + item.roleName), SecoundRow = item.status + (string.IsNullOrEmpty(item.subStatus)? "" : ", " + item.subStatus), Notes = (string.IsNullOrEmpty(item.notes) ? "" : item.notes), StatusChangedOn = item.statusChangedOn
                    });
                }
            }
            catch (Exception ex)
            {
                Debug.Write(ex.Message);
            }
        }
 public CityIncidentsController(IncidentService incidentService)
 {
     _incidentService = incidentService;
 }
Exemplo n.º 8
0
 public IncidentController(IncidentService incidentService, ReportService reportService, ILogger <IncidentController> logger)
 {
     this.incidentService = incidentService;
     this.reportService   = reportService;
     this.logger          = logger;
 }
        public List <IncidentResponse> GetFeildWorkerIncidents(string id)
        {
            var response = new IncidentService().GetIncidentByFieldWorkerId(id);

            return(response);
        }
        public IncidentResponse GetIncidentByID(string id)
        {
            var response = new IncidentService().GetIncidentById(id);

            return(response);
        }
 public SearchAreaController(IncidentService incidentService)
 {
     _incidentService = incidentService;
 }
        public string UpdateIncident(IncidentRequest incident)
        {
            var res = new IncidentService().UpdateIncident(incident);

            return("true");
        }
Exemplo n.º 13
0
 public IHttpActionResult Put([FromBody] Contracts.Incident.UpdateIncident update)
 {
     IncidentService.Update(update);
     return(Ok());
 }
Exemplo n.º 14
0
 public IHttpActionResult Delete(int id)
 {
     IncidentService.Delete(id);
     return(Ok());
 }
Exemplo n.º 15
0
 public IHttpActionResult Post([FromBody] Contracts.Incident.CreateIncident create)
 {
     IncidentService.Create(create);
     return(Ok());
 }
        public List <IncidentResponse> GetAllIncident()
        {
            var response = new IncidentService().GetAllIncident();

            return(response);
        }
Exemplo n.º 17
0
        public IHttpActionResult Get(int id)
        {
            var result = IncidentService.GetSingle(id);

            return(Ok(result));
        }
Exemplo n.º 18
0
        public IHttpActionResult Get([FromUri] PagedQuery pagedQuery)
        {
            var result = IncidentService.Get(pagedQuery);

            return(Ok(result));
        }
Exemplo n.º 19
0
 public IncidentController(DataContext context, IMapper mapper)
 {
     _service = new IncidentService(context, mapper);
 }