public IActionResult AddNewBed([FromBody] Beds bed) { try { bool validIcu = false; string message = ""; IcuValidator.CheckForValidIcu(bed.IcuNo, ref validIcu, ref message); if (!validIcu) { return(BadRequest(message)); } else { BedIdentification bedIdentification = new BedIdentification(); bed.BedSerialNo = bedIdentification.FindBedSerialNo(bed.IcuNo); _context.Add(bed); _context.SaveChanges(); return(Ok()); } } catch (Exception ex) { return(StatusCode(500, ex)); } }
public void FindBedSerialNumber_ShouldReturnBedSerialNumberGivenIcuNumber() { var _bedIdentification = new BedIdentification(); var _bedSerialNumber = _bedIdentification.FindBedSerialNo(1); Assert.True(_bedSerialNumber == _bedIdentification.FindCountOfBeds(1) + 1); }
public void FindCountOfBeds_ShouldGetTotalNumberOfBedsGivenIcuNo() { var _bedIdentification = new BedIdentification(); var _totalNoOfBeds = _bedIdentification.FindCountOfBeds(3); Assert.True(_totalNoOfBeds == 2); }
private static bool CheckIfIcuIsFull(int icuNo) { BedIdentification bedIdentification = new BedIdentification(); var bedSerialNo = bedIdentification.FindBedSerialNo(icuNo); if (bedSerialNo == 0) { return(true); } return(false); }
public ActionResult <IEnumerable <NumberOfBedsInIcu> > GetNumberOfBedsInEachIcu() { try { var icuStore = _context.Icu.ToList(); List <NumberOfBedsInIcu> numberOfBedsInIcu = new List <NumberOfBedsInIcu>(); BedIdentification bedIdentification = new BedIdentification(); foreach (Icu icu in icuStore) { numberOfBedsInIcu.Add(new NumberOfBedsInIcu { IcuRoomNo = icu.IcuNo, CountOfBeds = bedIdentification.FindCountOfBeds(icu.IcuNo) }); } return(Ok(numberOfBedsInIcu)); } catch (Exception) { return(StatusCode(500)); } }