/// <summary> /// CRUD: Read calls logicHelper to get all housingComplexes from service /// </summary> /// <returns>Task<HttpResponseMessage></returns> public async Task <HttpResponseMessage> Get() { try { var theResponse = Request.CreateResponse(HttpStatusCode.OK, await logicHelper.HousingDataGetAll()); log.Info("HousingData Get Successful"); return(theResponse); } catch (Exception ex) { LogHelper.SendError(log, ex); return(Request.CreateResponse(HttpStatusCode.BadRequest)); } }
/// <summary> /// method to get the current capacity of a given date /// </summary> /// <param name="dateTime"></param> /// <returns></returns> private async Task <int> findCurrCapDate(DateTime dateTime) { int value = 0; //List<AssociateDto> assoc = await consumerHelper.ConsumeAssociatesFromAPI(); //FIND THE APARTMENT List <HousingDataDto> dataList = await logicHelper.HousingDataGetAll(); List <HousingDataDto> returnList = new List <HousingDataDto>(); foreach (var item in dataList) { int b1 = (item.MoveInDate.CompareTo(dateTime)); int b2 = (dateTime.CompareTo(item.MoveOutDate)); if ((b1 == -1 || b1 == 0) && (b2 == 0 || b2 == 1)) { returnList.Add(item); } } List <ApartmentDto> aptDto = await logicHelper.ApartmentsGetAll(); foreach (var item in returnList) { if (item.RoomID != null) { ApartmentDto temp = aptDto.Find(id => id.RoomID.Equals(item.RoomID)); value += temp.CurrentCapacity; } } return(value); }