예제 #1
0
        private  string GetEmailTemplate(CreateCouponViewModel createCouponVm,IMyMentorRepository repository)
        {
            var currenctUserFullName = Session.GetLoggedInUser().GetFullName(Language.CurrentLanguageCode);
            var teacherFullName = createCouponVm.TeacherData.TeacherFullName;

            var currencyRetriever = new CurrencyRetriver(HttpContext, Session, repository);

            var itemType = repository.FindEntities().Single(x => x.EntityCode == EntityKeys.Coupons.ToString());
            var mailTemplate = new MailTemplate(Language.CurrentCulture);
          
            var emailData = new CouponEmailData();
            emailData.TeacherFullName =currenctUserFullName == teacherFullName ? createCouponVm.TeacherData.TeacherFullName:currenctUserFullName;
            emailData.CouponNumber = createCouponVm.CouponId;
            emailData.Event = createCouponVm.EventId;
            emailData.ItemNamePart1 = createCouponVm.ContentItemDetails.NamePart1;
            emailData.ItemNamePart2 = createCouponVm.ContentItemDetails.NamePart2;
            emailData.ItemType = itemType.GetLocalizedField("EntityName");
            emailData.OriginalPriceWithCurrency = createCouponVm.ContentItemDetails.FormattedOriginalPrice;
            emailData.StudentPriceWithCurrency = createCouponVm.CouponDiscountPrice.ToCurrency(currencyRetriever.GetCurrent());
            emailData.ValidUntil = createCouponVm.CouponValidUntil;
            emailData.PurchaseDate = DateTime.Now.ToString("dd/MM/yyyy");
            if (!string.IsNullOrEmpty(createCouponVm.EventId))
            {
                emailData.Event = string.Format(MyMentorResources.couponLetterEventPlaceholder, createCouponVm.EventId);
            }            
           
            var mailForStudent = mailTemplate.GetCouponEmail(emailData);
            return mailForStudent;
        }