Exemple #1
0
        public void Put(Guid id, [FromBody] ScreeningDataTable value)
        {
            var entity = this.dataContext.Screenings.First(x => x.Id == id);

            Screening.CopyPropertyValues(value, entity);
            this.dataContext.Update(entity);
            this.dataContext.SaveChanges();
        }
Exemple #2
0
        public ActionResult <ScreeningDataTable> Post([FromBody] ScreeningDataTable value)
        {
            var  dataObject = Screening.FromApiModel(value);
            Guid newId      = Guid.NewGuid();

            dataObject.Id = newId;
            this.dataContext.Screenings.Add(dataObject);
            this.dataContext.SaveChanges();
            var result = ScreeningDataTable.FromDataModel(
                this.dataContext.Screenings.First(x => x.Id == newId)
                );
            var resultUrl = string.Concat(configuration["SwaggerBaseUrl"], $"/ScreeningDataTable/{newId}");

            return(Created(resultUrl, result));
        }
 internal static void CopyPropertyValues(ScreeningDataTable from, Screening to)
 {
     to.Bodyache             = from.Bodyache;
     to.ContactNumber        = from.ContactNumber;
     to.DateOfScreening      = from.DateOfScreening;
     to.DryCough             = from.DryCough;
     to.Fatigue              = from.Fatigue;
     to.Fever                = from.Fever;
     to.Headache             = from.Headache;
     to.InContactWithCOVID   = from.InContactWithCOVID;
     to.Location             = from.Location;
     to.Nationality          = from.Nationality;
     to.Passport             = from.Passport;
     to.RunnyNose            = from.RunnyNose;
     to.ScreeningRepName     = from.ScreeningRepName;
     to.ShortnessOfBreath    = from.ShortnessOfBreath;
     to.SoreThroat           = from.SoreThroat;
     to.TraveledOutsideTheUS = from.TraveledOutsideTheUS;
     to.VisitorName          = from.VisitorName;
 }
 internal static Screening FromApiModel(ScreeningDataTable apiModel)
 {
     return(new Screening
     {
         Id = apiModel.Id,
         Bodyache = apiModel.Bodyache,
         ContactNumber = apiModel.ContactNumber,
         DateOfScreening = apiModel.DateOfScreening,
         DryCough = apiModel.DryCough,
         Fatigue = apiModel.Fatigue,
         Fever = apiModel.Fever,
         Headache = apiModel.Headache,
         InContactWithCOVID = apiModel.InContactWithCOVID,
         Location = apiModel.Location,
         Nationality = apiModel.Nationality,
         Passport = apiModel.Passport,
         RunnyNose = apiModel.RunnyNose,
         ScreeningRepName = apiModel.ScreeningRepName,
         ShortnessOfBreath = apiModel.ShortnessOfBreath,
         SoreThroat = apiModel.SoreThroat,
         TraveledOutsideTheUS = apiModel.TraveledOutsideTheUS,
         VisitorName = apiModel.VisitorName
     });
 }
Exemple #5
0
 public IEnumerable <ScreeningDataTable> Get()
 {
     return(this.dataContext.Screenings
            .OrderBy(x => x.VisitorName)
            .Select(x => ScreeningDataTable.FromDataModel(x)));
 }