public static void GetOffer(int id, int offerId, out Offer offer, ILocalisationRepository lRepo, IOfferRepository oRepo, Func<ActionResult> caseError) { //case no offer selected, take the first one if (offerId == 0) { var loc = lRepo.Get(id); offer = loc.Offers.FirstOrDefault(); if (offer == null) { caseError.Invoke(); } } else { offer = oRepo.Get(offerId); } }
public static DropDownModel GetOfferDropDown(Offer offer, Func<Offer,string> urlMaker, OfferDropDownFilter filter = OfferDropDownFilter.None) { var dropDown = new DropDownModel { Id = DropDownModel.OfferDD, Title = offer.Name, Items = new List<DropDownItem>() }; foreach (var item in offer.Localisation.Offers) { switch (filter) { case OfferDropDownFilter.Quotation: { if (item.AcceptQuotation()) dropDown.Items.Add(new DropDownItem { DisplayName = item.Name, Link = urlMaker(item) }); break; } case OfferDropDownFilter.Booking: { if (item.AcceptBooking()) dropDown.Items.Add(new DropDownItem { DisplayName = item.Name, Link = urlMaker(item) }); break; } case OfferDropDownFilter.None: default: dropDown.Items.Add(new DropDownItem { DisplayName = item.Name, Link = urlMaker(item) }); break; } } return dropDown; }