예제 #1
0
 public BonusDto Resolve(History source, HistoryDto destination, BonusDto destMember, ResolutionContext context)
 {
     try
     {
         return(_mapper.Map <BonusDto>(_bonusService.FindBonusByIdAsync(source.BonusId).GetAwaiter()
                                       .GetResult()));
     }
     catch
     {
         //Vendor does not finded by Id
         return(new BonusDto());
     }
 }
예제 #2
0
        public async Task Bonus_FindBonusByIdAsync_Return_BonusDTO()
        {
            CreateDefaultBonusServiceInstance();
            var idBonus = _fakeBonuseDtos[0].Id;

            var bonus = await _bonusService.FindBonusByIdAsync(idBonus, default(CancellationToken));

            Assert.NotNull(bonus);
        }
예제 #3
0
        public async Task SendEmailAsync(History history)
        {
            var user = await _userService.GetUserAsync(history.CreatorId.ToString());

            var bonus = await _bonusService.FindBonusByIdAsync(history.BonusId);

            var vendor =
                await _vendorService.GetVendorByIdAsync(bonus.Company.Id);

            string promoCode = vendor.Name + RandomString(5);
            var    strToUser = String.Format("Hi {0} {1} your order recived. You ordered {2} by {3} company." +
                                             " For more information, please call {4} or email {5}." +
                                             " Validity period from {6} to {7}." +
                                             " Your promo code is {8}",
                                             user.FirstName, user.LastName,
                                             bonus.Title, bonus.Company.Name, bonus.Phone, vendor.Email, bonus.DateStart, bonus.DateEnd,
                                             promoCode);
            var strToVendor = String.Format("Dear {0},  {1} {2} will come to you with promo. PromoCode is {3}",
                                            vendor.Name, user.FirstName, user.LastName, promoCode);



            MimeMessage messageToUser = new MimeMessage();

            messageToUser.From.Add(new MailboxAddress(vendor.Name, vendor.Email));
            messageToUser.To.Add(new MailboxAddress(user.Email));
            messageToUser.Subject = "Get bonus";
            messageToUser.Body    = new BodyBuilder()
            {
                HtmlBody = String.Format("<div>{0}</div>", strToUser)
            }.ToMessageBody();


            MimeMessage messageToVendor = new MimeMessage();

            messageToVendor.From.Add(new MailboxAddress(user.FirstName, user.Email));
            messageToVendor.To.Add(new MailboxAddress(vendor.Email));
            messageToVendor.Subject = "Get bonus";
            messageToVendor.Body    = new BodyBuilder()
            {
                HtmlBody = String.Format("<div>{0}</div>", strToVendor)
            }.ToMessageBody();

            using (MailKit.Net.Smtp.SmtpClient client = new MailKit.Net.Smtp.SmtpClient())
            {
                client.Connect(_emailSettings.Value.SMTPServer, _emailSettings.Value.SMTPServerPort, true);
                client.Authenticate(_emailSettings.Value.EmailAddress, _emailSettings.Value.Password);
                client.Send(messageToUser);
                client.Send(messageToVendor);
                client.Disconnect(true);
            }
        }
예제 #4
0
 public async Task <ActionResult <ResultDto <IEnumerable <BonusDto> > > > FindBonusByIdAsync([FromRoute] Guid id)
 {
     return(Ok(await _BonusService.FindBonusByIdAsync(id)));
 }