Last post Oct 31, 2016 07:50 AM by Deepak Panchal
Oct 29, 2016 08:09 PM|ajs1351|LINK
What im trying to do , if the condition is met, deduct 1 from that variable. but the problem, if there are three items in the list, that needs to be deduct, only the last one gets deducted, which then next iteration check, its not accurate. putting
in a forloop to iterate through the list does not do it, so i dont know what else Im missing.
public void ReserveRoom(List<ReservationType> reservation)
List<ReservationType> RequestReservation = new List<ReservationType>();
RequestReservation = reservation; //List that contains the test cases.
string reservationid = "0001";
int number = int.Parse(reservationid);
int count = 0;
foreach (ReservationType requestReservation in RequestReservation)
List<String> DateList = CreateDateList(requestReservation.StartDate, requestReservation.numDays);
foreach (Inventory inventory in RoomInventory)
if (requestReservation.hotelId.Equals (inventory.HotelId))
if (requestReservation.roomType == inventory.RoomType)
for (int i = 0; i < DateList.Count; i++)
if (DateList[i].Equals(inventory.Date) && inventory.Quantity > 0)
if (requestReservation.numDays == count)
for (int j = 0; j < DateList.Count; j++)
requestReservation.reservationId = "000" + (number + 1).ToString();
requestReservation.result = ReservationType.ReservationResultType.Success;
count = 0;
foreach (Hotels h in LHotels)
foreach (Room rm in h.RoomList)
if (requestReservation.hotelId == h.HotelId && requestReservation.roomType == rm.RoomType)
requestReservation.cost = (requestReservation.numDays * rm.Rate);
} // end of if num == counts
requestReservation.reservationId = null;
requestReservation.result = ReservationType.ReservationResultType.RoomNotAvailable;
count = 0;
} //end of if
}//end of forloop
}//end of if statement (Roomtypes)
}//end of If statement( inventory.hotelID)
} // end of foreach inventory
}// end of Foreach
serial = new XmlSerializer(RequestReservation.GetType());
sw = new StreamWriter(ReservationFilename);
}// End of ReserveRoom Method
Oct 31, 2016 07:50 AM|Deepak Panchal|LINK
we are not able to run the code mentioned by you because there are so many objects in that code that we don't know about how you declare in your code.
you had mentioned that ," if there are three items in the list, that needs to be deduct, only the last one gets deducted, which then next iteration check, its not accurate.
do you mean you want to remove all the items from the list?
if possible please try to create a simple demo of your problem that we can run on our side and reproduce the issue.
so that we can try to look in to that and try to help you.
then you can implement that solution in your original code.