public async Task <IActionResult> Create() { var site = await GetCurrentSiteAsync(); var siteUrl = await _siteService.GetBaseUrl(Request.Scheme, Request.Host.Value); var viewModel = new TriggersDetailViewModel { Action = "Create", IsSecretCode = true, BadgeMakerUrl = GetBadgeMakerUrl(siteUrl, site.FromEmailAddress), UseBadgeMaker = true, EditAvatarBundle = UserHasPermission(Permission.ManageAvatars), EditMail = UserHasPermission(Permission.ManageTriggerMail), EditVendorCode = UserHasPermission(Permission.ManageVendorCodes), SystemList = new SelectList((await _siteService.GetSystemList()), "Id", "Name"), BranchList = new SelectList((await _siteService.GetAllBranches()), "Id", "Name"), ProgramList = new SelectList((await _siteService.GetProgramList()), "Id", "Name") }; if (viewModel.EditVendorCode) { viewModel.VendorCodeTypeList = new SelectList( (await _vendorCodeService.GetTypeAllAsync()), "Id", "Description"); } if (viewModel.EditAvatarBundle) { viewModel.UnlockableAvatarBundleList = new SelectList( await _dynamicAvatarService.GetAllBundlesAsync(true), "Id", "Name"); } PageTitle = "Create Trigger"; return(View("Detail", viewModel)); }
public async Task <IActionResult> Index() { if (UserHasPermission(Permission.ManageVendorCodes)) { var vendorCodeStatus = await _vendorCodeService.GetStatusAsync(); if (vendorCodeStatus.IsConfigured) { return(View(vendorCodeStatus)); } else { var vendorCodeType = await _vendorCodeService.GetTypeAllAsync(); if (vendorCodeType?.Count == 0) { return(RedirectToAction(nameof(Configure))); } else { return(RedirectToAction(nameof(GenerateCodes))); } } } return(RedirectToAction(nameof(ViewPackingSlip))); }
public async Task <IActionResult> ImportStatus() { var codeTypes = await _vendorCodeService.GetTypeAllAsync(); var codeTypeSelectList = codeTypes.Select(_ => new SelectListItem { Value = _.Id.ToString(), Text = _.Description }); PageTitle = "Vendor Code Import Status"; return(View(codeTypeSelectList)); }
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")); }
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")); }
public async Task <IActionResult> Configure(int id) { var report = _reportService.GetReportList().SingleOrDefault(_ => _.Id == id); if (report == null) { AlertDanger = $"Could not find report of type {id}."; return(RedirectToAction("Index")); } PageTitle = $"Configure {report.Name}"; string viewName = report.Name.Replace(" ", string.Empty); if (viewName.EndsWith("Report")) { viewName = viewName.Substring(0, viewName.Length - 6); } var systemList = await _siteService.GetSystemList(true); var branchList = await _siteService.GetAllBranches(true); var programList = await _siteService.GetProgramList(); var schoolDistrictList = await _schoolService.GetDistrictsAsync(); var schoolList = await _schoolService.GetSchoolsAsync(schoolDistrictList.FirstOrDefault()?.Id); var groupInfoList = await _userService.GetGroupInfosAsync(); var vendorCodeTypeList = await _vendorCodeService.GetTypeAllAsync(); var site = await GetCurrentSiteAsync(); var triggerList = await _triggerService.GetTriggersAwardingPrizesAsync(); foreach (var trigger in triggerList) { trigger.AwardPrizeName += $" ({trigger.Name})"; } return(View($"{viewName}Criteria", new ReportCriteriaViewModel { ReportId = id, ProgramStartDate = site.ProgramStarts ?? new DateTime(2018, 01, 01), SystemList = new SelectList(systemList, "Id", "Name"), BranchList = new SelectList(branchList, "Id", "Name"), ProgramList = new SelectList(programList, "Id", "Name"), SchoolDistrictList = new SelectList(schoolDistrictList, "Id", "Name"), SchoolList = new SelectList(schoolList, "Id", "Name"), GroupInfosList = new SelectList(groupInfoList, "Id", "Name"), VendorCodeTypeList = new SelectList(vendorCodeTypeList, "Id", "Description"), PrizeList = new SelectList(triggerList, "Id", "AwardPrizeName") })); }
public async Task <IActionResult> Create() { var site = await GetCurrentSiteAsync(); var siteUrl = await _siteService.GetBaseUrl(Request.Scheme, Request.Host.Value); TriggersDetailViewModel viewModel = new TriggersDetailViewModel() { Action = "Create", IsSecretCode = true, BadgeMakerUrl = GetBadgeMakerUrl(siteUrl, site.FromEmailAddress), UseBadgeMaker = true, SystemList = new SelectList((await _siteService.GetSystemList()), "Id", "Name"), BranchList = new SelectList((await _siteService.GetAllBranches()), "Id", "Name"), ProgramList = new SelectList((await _siteService.GetProgramList()), "Id", "Name"), VendorCodeTypeList = new SelectList( (await _vendorCodeService.GetTypeAllAsync()), "Id", "Name") }; PageTitle = "Create Trigger"; return(View("Detail", viewModel)); }
public async Task <IActionResult> CreateVendorCodes(int numberOfCodes) { var allCodes = await _vendorCodeService.GetTypeAllAsync(); var code = allCodes.FirstOrDefault(); if (code == null) { code = await _vendorCodeService.AddTypeAsync(new VendorCodeType { Description = "Free Book Code", OptionSubject = "Choose whether to receive your free book or donate it to a child", OptionMail = "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 jobToken = await _jobService.CreateJobAsync(new Job { JobType = JobType.GenerateVendorCodes, SerializedParameters = JsonConvert.SerializeObject( new JobDetailsGenerateVendorCodes { NumberOfCodes = numberOfCodes, VendorCodeTypeId = code.Id, CodeLength = 15 }) }); return(View("Job", new ViewModel.MissionControl.Shared.JobViewModel { CancelUrl = Url.Action(nameof(Index)), JobToken = jobToken.ToString(), PingSeconds = 5, SuccessRedirectUrl = "", SuccessUrl = Url.Action(nameof(Index)), Title = "Generating vendor codes..." })); }