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()); } }
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); } }
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); } }
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()); } }
public IHttpActionResult Search(string query) { if (!string.IsNullOrEmpty(query) && query.Length > 1) { return(Ok(IncidentService.Search(query))); } else { return(Ok(new List <SimpleSearchResult>())); } }
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; }
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"); }
public IHttpActionResult Put([FromBody] Contracts.Incident.UpdateIncident update) { IncidentService.Update(update); return(Ok()); }
public IHttpActionResult Delete(int id) { IncidentService.Delete(id); return(Ok()); }
public IHttpActionResult Post([FromBody] Contracts.Incident.CreateIncident create) { IncidentService.Create(create); return(Ok()); }
public List <IncidentResponse> GetAllIncident() { var response = new IncidentService().GetAllIncident(); return(response); }
public IHttpActionResult Get(int id) { var result = IncidentService.GetSingle(id); return(Ok(result)); }
public IHttpActionResult Get([FromUri] PagedQuery pagedQuery) { var result = IncidentService.Get(pagedQuery); return(Ok(result)); }
public IncidentController(DataContext context, IMapper mapper) { _service = new IncidentService(context, mapper); }