Пример #1
0
        public IActionResult ConsentEditor(int consentGroupId, int consentId)
        {
            var consent = consentId > 0
                ? _consentService.Get(consentId)
                : new Consent()
            {
                ConsentGroup = new ConsentGroup()
                {
                    Id = consentGroupId
                },
                ConsentGroupId = consentGroupId
            };

            if (consent == null || consent.ConsentGroupId != consentGroupId)
            {
                return(NotFound());
            }
            var model = _gdprModelFactory.Create(consent);

            //get available groups
            var consentGroups           = _consentGroupService.Get(x => true).OrderBy(x => x.Name).ToList();
            var consentGroupsSelectList = SelectListHelper.GetSelectItemList(consentGroups, x => x.Id, x => x.Name);

            return(R.Success.With("consent", model).With("consentGroups", consentGroupsSelectList).Result);
        }
Пример #2
0
        public IActionResult Consents()
        {
            var userConsents  = _gdprService.GetUserConsents(CurrentUser.Id);
            var allConsents   = _consentService.Get(x => x.Published).GroupBy(x => x.ConsentGroup).ToList();
            var consentGroups = new List <ConsentGroupModel>();
            var acceptedIds   = userConsents.Where(x => x.ConsentStatus == ConsentStatus.Accepted)
                                .Select(x => x.ConsentId).ToArray();
            var deniedIds = userConsents.Where(x => x.ConsentStatus == ConsentStatus.Denied)
                            .Select(x => x.ConsentId).ToArray();

            foreach (var ac in allConsents)
            {
                var group = ac.Key ?? new ConsentGroup()
                {
                    Consents = ac.ToList()
                };
                consentGroups.Add(_gdprModelFactory.Create(group, acceptedIds, deniedIds));
            }

            return(R.Success.With("consentGroups", consentGroups).Result);
        }