예제 #1
0
        public async Task <IActionResult> BundleEdit(int id)
        {
            var bundle = new Domain.Model.DynamicAvatarBundle();

            try
            {
                bundle = await _avatarService.GetBundleByIdAsync(id);
            }
            catch (GraException gex)
            {
                ShowAlertWarning("Unable to view bundle: ", gex);
                return(RedirectToAction("Bundles"));
            }
            foreach (var item in bundle.DynamicAvatarItems)
            {
                item.Thumbnail = _pathResolver.ResolveContentPath(item.Thumbnail);
            }

            var viewModel = new BundlesDetailViewModel()
            {
                Bundle    = bundle,
                Action    = "Edit",
                ItemsList = string.Join(",", bundle.DynamicAvatarItems.Select(_ => _.Id)),
                Layers    = new SelectList(await _avatarService.GetLayersAsync(), "Id", "Name")
            };

            if (bundle.CanBeUnlocked)
            {
                viewModel.TriggersAwardingBundle = await _avatarService
                                                   .GetTriggersAwardingBundleAsync(id);
            }

            PageTitle = "Edit Bundle";
            return(View("BundleDetail", viewModel));
        }
예제 #2
0
        public async Task <JsonResult> GetItemsInBundleAsync(int id)
        {
            var bundle = await _dynamicAvatarService.GetBundleByIdAsync(id, true);

            var thumbnailList = bundle.DynamicAvatarItems
                                .Select(_ => _pathResolver.ResolveContentPath(_.Thumbnail))
                                .ToList();

            return(Json(thumbnailList));
        }
예제 #3
0
        public async Task <IActionResult> Edit(int id)
        {
            var trigger = await _triggerService.GetByIdAsync(id);

            var site = await GetCurrentSiteAsync();

            var siteUrl = await _siteService.GetBaseUrl(Request.Scheme, Request.Host.Value);

            var viewModel = new TriggersDetailViewModel
            {
                Trigger               = trigger,
                Action                = "Edit",
                IsSecretCode          = !string.IsNullOrWhiteSpace(trigger.SecretCode),
                BadgeMakerUrl         = GetBadgeMakerUrl(siteUrl, site.FromEmailAddress),
                UseBadgeMaker         = true,
                EditAvatarBundle      = UserHasPermission(Permission.ManageAvatars),
                EditMail              = UserHasPermission(Permission.ManageTriggerMail),
                EditVendorCode        = UserHasPermission(Permission.ManageVendorCodes),
                AwardsMail            = !string.IsNullOrWhiteSpace(trigger.AwardMailSubject),
                AwardsPrize           = !string.IsNullOrWhiteSpace(trigger.AwardPrizeName),
                DependentTriggers     = await _triggerService.GetDependentsAsync(trigger.AwardBadgeId),
                TriggerRequirements   = await _triggerService.GetTriggerRequirementsAsync(trigger),
                BadgeRequiredList     = string.Join(",", trigger.BadgeIds),
                ChallengeRequiredList = string.Join(",", trigger.ChallengeIds),
                SystemList            = new SelectList((await _siteService.GetSystemList()), "Id", "Name"),
                ProgramList           = new SelectList((await _siteService.GetProgramList()), "Id", "Name")
            };

            if (viewModel.EditVendorCode)
            {
                viewModel.VendorCodeTypeList = new SelectList(
                    (await _vendorCodeService.GetTypeAllAsync()), "Id", "Description");
            }
            else if (viewModel.Trigger.AwardVendorCodeTypeId.HasValue)
            {
                viewModel.VendorCodeType = (await _vendorCodeService
                                            .GetTypeById(viewModel.Trigger.AwardVendorCodeTypeId.Value)).Description;
            }

            if (viewModel.EditAvatarBundle)
            {
                viewModel.UnlockableAvatarBundleList = new SelectList(
                    await _dynamicAvatarService.GetAllBundlesAsync(true), "Id", "Name");
            }
            else if (viewModel.Trigger.AwardAvatarBundleId.HasValue)
            {
                viewModel.UnlockableAvatarBundle = (await _dynamicAvatarService
                                                    .GetBundleByIdAsync(viewModel.Trigger.AwardAvatarBundleId.Value)).Name;
            }

            if (viewModel.Trigger.LimitToSystemId.HasValue)
            {
                viewModel.BranchList = new SelectList(
                    (await _siteService.GetBranches(viewModel.Trigger.LimitToSystemId.Value)), "Id", "Name");
            }
            else
            {
                viewModel.BranchList = new SelectList((await _siteService.GetAllBranches()), "Id", "Name");
            }
            foreach (var requirement in viewModel.TriggerRequirements)
            {
                if (!string.IsNullOrWhiteSpace(requirement.BadgePath))
                {
                    requirement.BadgePath = _pathResolver.ResolveContentPath(requirement.BadgePath);
                }
            }
            if (!string.IsNullOrWhiteSpace(viewModel.Trigger.AwardBadgeFilename))
            {
                viewModel.BadgePath = _pathResolver.ResolveContentPath(viewModel.Trigger.AwardBadgeFilename);
            }

            if (UserHasPermission(Permission.ManageEvents))
            {
                viewModel.RelatedEvents = await _eventService.GetRelatedEventsForTriggerAsync(id);
            }
            PageTitle = $"Edit Trigger - {viewModel.Trigger.Name}";
            return(View("Detail", viewModel));
        }