/// <summary> /// Function that collects Camping spots based upon if power is required /// </summary> /// <param name="BookingNeedsElectricity"></param> /// <returns></returns> public static List <Camping> FetchCampingSpots(bool BookingNeedsElectricity) { Camping2000Db Db = new Camping2000Db(); List <Camping> allSpots = Db.Camping.ToList(); if (allSpots == null) { allSpots[0].CampingSpot = "NoData"; return(allSpots); } List <Camping> ListOfSpots = new List <Camping>(); foreach (var spot in allSpots) { if (spot.CampingElectricity == BookingNeedsElectricity) { ListOfSpots.Add(spot); } } return(ListOfSpots); }
// /// <summary> // /// Function that accepts one or two strings and return a list of guests // /// </summary> // /// <param name="firstName"></param> // /// <param name="lastName"></param> // /// <returns></returns> public static List <ApplicationUser> SearchForPeople(string firstName, string lastName) { Camping2000Db Db = new Camping2000Db(); List <ApplicationUser> foundGuests = new List <ApplicationUser>(); firstName = firstName.ToLower(); lastName = lastName.ToLower(); if ((firstName != "") && (lastName == "")) { foreach (var guest in Db.Users) { if (guest.GuestFirstName.ToLower() == firstName) { foundGuests.Add(guest); } } } else if ((firstName != "") && (lastName != "")) { foreach (var guest in Db.Users) { if ((guest.GuestFirstName.ToLower() == firstName) && (guest.GuestLastName.ToLower() == lastName)) { foundGuests.Add(guest); } } } else if ((firstName == "") && (lastName != "")) { foreach (var guest in Db.Users) { if (guest.GuestLastName.ToLower() == lastName) { foundGuests.Add(guest); } } } return(foundGuests); }