public PhoneBl Capture(OfferBl chosenOffer, int generatedNumber) { var newPhone = new PhoneBl { Offer = chosenOffer, PhoneNumber = generatedNumber, SecondsLeftInBundle = chosenOffer.BundleOfMinutes * _secondsInMinute, TextMessagesLeftInBundle = chosenOffer.BundleOfTextMessages }; return(newPhone); }
public async Task <HttpResponseMessage> AddAnOfferAsync([FromBody] OfferBl offer) { try { var offerId = await _offerService.AddAnOfferAsync(offer); return(Request.CreateResponse(HttpStatusCode.OK, offerId)); } catch (Exception e) { var message = $"Adding new offer failde. {e.Message}"; return(Request.CreateResponse(HttpStatusCode.BadRequest, message)); } }
public OfferBl Capture() { var newOffer = new OfferBl { Name = _ioHelper.GetStringFromUser("Enter the name of the offer: "), BundleOfMinutes = _ioHelper.GetIntFromUser("Enter the bundle of minutes according to the offer: "), BundleOfTextMessages = _ioHelper.GetIntFromUser("Enter the bundle of short text messages according to the offer: "), PricePerMinute = _ioHelper.GetDecimalFromUser("Enter the price per minute outside of the bundle: "), PricePerTextMessage = _ioHelper.GetDecimalFromUser("Enter the price per text message outside of the bundle: "), PriceOfTheOffer = _ioHelper.GetDecimalFromUser("Enter the price of declared offer: ") }; return(newOffer); }
public OfferBl MapOfferToOfferBl(Offer offer) { var offerBl = new OfferBl { Id = offer.Id, Name = offer.Name, BundleOfMinutes = offer.BundleOfMinutes, BundleOfTextMessages = offer.BundleOfTextMessages, PricePerMinute = offer.PricePerMinute, PricePerTextMessage = offer.PricePerTextMessage, PriceOfTheOffer = offer.PriceOfTheOffer }; return(offerBl); }
public Offer MapOfferBlToOffer(OfferBl offerBl) { var offer = new Offer { Id = offerBl.Id, Name = offerBl.Name, BundleOfMinutes = offerBl.BundleOfMinutes, BundleOfTextMessages = offerBl.BundleOfTextMessages, PricePerMinute = offerBl.PricePerMinute, PricePerTextMessage = offerBl.PricePerTextMessage, PriceOfTheOffer = offerBl.PriceOfTheOffer }; return(offer); }
public async Task <int> AddAnOfferAsync(OfferBl offerBl) { var offer = _dataObjectMapper.MapOfferBlToOffer(offerBl); using (var dbContext = _dbContextFactory()) { if (await dbContext.OfferDbSet.AnyAsync(o => o.Name == offer.Name)) { throw new Exception("There is already an offer with given name"); } await Task.Run(() => { dbContext.OfferDbSet.Add(offer); dbContext.SaveChanges(); }); return(offer.Id); } }
public PhoneBl CapturePhone(OfferBl chosenOffer, int generatedNumber) { return(_phoneDataCapture.Capture(chosenOffer, generatedNumber)); }
public void DisplayOffer(OfferBl offer) { _ioHelper.PrintMessage($"Name of the offer: {offer.Name} {Environment.NewLine}" + $"Price of the offer: {offer.PriceOfTheOffer} {Environment.NewLine}"); }
public async Task AddAnOfferAsync(OfferBl offerBl) { await _offerService.AddAnOfferAsync(offerBl); }