public PremiumOfferViewModel ToPremiumOfferViewModel(PremiumOffer model) { var offer = new PremiumOfferViewModel { Id = model.Id, Title = model.Title, Conditions = string.IsNullOrEmpty(model.Conditions) ? string.Empty : model.Conditions, Quantity = model.Quantity, Price = model.Price, Type = model.Type, Image = model.Image, PartnerName = model.Partner.CompanyName, OfferGuidId = model.OfferIdGuid, }; if (model.Flight != null) { offer.AvailableSeats = model.Flight == null ? -1 : model.Flight.AvailableSeats; offer.Arrival = string.IsNullOrEmpty(model.Flight.Arrival) ? string.Empty : model.Flight.Arrival; offer.Departure = string.IsNullOrEmpty(model.Flight.Departure) ? string.Empty : model.Flight.Departure; offer.FlightDateTime = model.Flight.DepartureDate; } return(offer); }
public async Task <ActionResult> PremiumOfferDetails(int?id) { if (id == null) { return(new NotFoundViewResult("_Error404")); } var entityList = await _premiumRepository.GetAllIncludes(); PremiumOffer selectedPremiumOffer = entityList .Where(a => a.Id.Equals(id.Value)) .FirstOrDefault(); return(PartialView("_PremiumOfferDetails", _converterHelper.ToPremiumOfferViewModel(selectedPremiumOffer))); }
public Transaction CreatePurchaseTransaction(User user, PremiumOffer offer) { var transaction = new Transaction { StartBalance = user.BonusMiles, CreatedBy = user, CreateDate = DateTime.UtcNow, TransactionType = Enums.TransactionType.Debit, Value = offer.Price, Product = offer, Status = 0 }; transaction.EndBalance = transaction.StartBalance - transaction.Value; return(transaction); }
public PremiumOfferViewModel ToPremiumOfferViewModel(PremiumOffer model) { var offer = new PremiumOfferViewModel { Id = model.Id, Title = model.Title, FlightId = model.Flight == null ? 0 : model.Flight.Id, Conditions = string.IsNullOrEmpty(model.Conditions) ? string.Empty : model.Conditions, Quantity = model.Quantity, Price = model.Price, AvailableSeats = model.Flight == null ? -1 : model.Flight.AvailableSeats, Type = model.Type, Image = model.Image, PartnerName = model.Partner.CompanyName, OfferGuidId = model.OfferIdGuid, Arrival = model.Flight != null ? (string.IsNullOrEmpty(model.Flight.Arrival) ? string.Empty : model.Flight.Arrival) : string.Empty, Departure = model.Flight != null ? (string.IsNullOrEmpty(model.Flight.Departure) ? string.Empty : model.Flight.Departure) : string.Empty, FlightDateTime = model.Flight != null ? model.Flight.DepartureDate : new DateTime?(), CreatedOn = model.CreateDate }; return(offer); }