Ejemplo n.º 1
0
 private void MakeTracingCentre1()
 {
     tracingCentre1 = new TracingCentre
     {
         Name     = "Tracing Centre #1",
         Postcode = "FG34 HIJ"
     };
 }
        public TracingCentre Update(TracingCentre updatedTracingCentre)
        {
            var TracingCentre = context.TracingCentres.Attach(updatedTracingCentre);

            TracingCentre.State = Microsoft.EntityFrameworkCore.EntityState.Modified;
            context.SaveChanges();
            return(updatedTracingCentre);
        }
Ejemplo n.º 3
0
 int ICaseService.CasesTracedByTracingCentreLast28Days(TracingCentre centre)
 {
     return(_caseRepository.GetCasesByDate(DateTime.Now.AddDays(-28), DateTime.Now)
            .Where(x => x.Traced)
            .Where(x => x.Tracer.TracingCentre.TracingCentreID == centre.TracingCentreID)
            .ToList()
            .Count());
 }
        public void A30_GetTracingCentreTest()
        {
            IEnumerable <TracingCentre> allCentres = tracingCentreRepository.GetAllTracingCentres();
            TracingCentre baseCentre = allCentres.First();

            TracingCentre centreFromDb = tracingCentreRepository.GetTracingCentre(baseCentre.TracingCentreID);

            Assert.AreEqual(baseCentre.Name, centreFromDb.Name);
        }
        public TracingCentre Delete(int id)
        {
            TracingCentre deleting = context.TracingCentres.Find(id);

            if (deleting != null)
            {
                context.TracingCentres.Remove(deleting);
                context.SaveChanges();
            }
            return(deleting);
        }
        public void A40_UpdateTest()
        {
            IEnumerable <TracingCentre> allCentres = tracingCentreRepository.GetAllTracingCentres();
            TracingCentre baseCentre = allCentres.First();

            baseCentre.Name = "Updated Name";
            tracingCentreRepository.Update(baseCentre);

            TracingCentre centreFromDb2 = tracingCentreRepository.GetTracingCentre(baseCentre.TracingCentreID);

            Assert.AreEqual(baseCentre.Name, centreFromDb2.Name);
        }
Ejemplo n.º 7
0
        TimeSpan ICaseService.AverageTraceTimeOfCentreLast28Days(TracingCentre centre)
        {
            var cases = _caseRepository.GetCasesByDate(DateTime.Now.AddDays(-28), DateTime.Now)
                        .Where(x => x.Traced == true)
                        .Where(x => x.Tracer.TracingCentreID == centre.TracingCentreID);
            var total_ticks = cases.Select(x => x.TracedDate.Value.Ticks - x.AddedDate.Ticks).Sum();
            var num_cases   = cases.ToList().Count();

            if (num_cases == 0)
            {
                return(TimeSpan.FromTicks(0));
            }
            return(TimeSpan.FromTicks(total_ticks / num_cases));
        }
 public TracingCentre Add(TracingCentre newTracingCentre)
 {
     context.TracingCentres.Add(newTracingCentre);
     context.SaveChanges();
     return(newTracingCentre);
 }