Пример #1
0
        public async Task <IActionResult> CreateVendorCodesAsync(int numberOfCodes)
        {
            var allCodes = await _vendorCodeService.GetTypeAllAsync();

            var code = allCodes.FirstOrDefault();

            if (code == null)
            {
                code = await _vendorCodeService.AddTypeAsync(new VendorCodeType
                {
                    Description           = "Free Book Code",
                    DonationOptionSubject = "Choose whether to receive your free book or donate it to a child",
                    DonationOptionMail    = "If you'd like to redeem your free book code, please visit <a href=\"/Profile/\">your profile</a> and select the redeem option. If you're not interested in redeeming it, you can select the option to donate it to a child.",
                    MailSubject           = "Here's your Free Book Code!",
                    Mail            = $"Congratulations, you've earned a free book! Your free book code is: {TemplateToken.VendorCodeToken}!",
                    DonationMessage = "Your free book has been donated.Thank you!!!",
                    DonationSubject = "Thank you for donating your free book!",
                    DonationMail    = "Thanks so much for the donation of your book.",
                    Url             = "http://freebook/?Code={Code}"
                });
            }
            var sw = new Stopwatch();

            sw.Start();
            var generatedCount = await _vendorCodeService.GenerateVendorCodesAsync(code.Id, numberOfCodes);

            sw.Stop();

            AlertSuccess = $"Generated {generatedCount} codes in {sw.Elapsed.TotalSeconds} seconds of type: {code.Description}";

            return(View("Index"));
        }
Пример #2
0
        public async Task <IActionResult> CreateVendorCodesAsync(int numberOfCodes)
        {
            var allCodes = await _vendorCodeService.GetTypeAllAsync();

            var code = allCodes.FirstOrDefault();

            if (code == null)
            {
                code = await _vendorCodeService.AddTypeAsync(new VendorCodeType
                {
                    Description = "Free Book Code",
                    MailSubject = "Here's your Free Book Code!",
                    Mail        = "Congratulations, you've earned a free book! Your free book code is {Code}!",
                });
            }
            var sw = new Stopwatch();

            sw.Start();
            var generatedCount = await _vendorCodeService.GenerateVendorCodesAsync(code.Id, numberOfCodes);

            sw.Stop();

            AlertSuccess = $"Generated {generatedCount} codes in {sw.Elapsed.TotalSeconds} seconds of type: {code.Description}";

            return(View("Index"));
        }