Esempio n. 1
0
        public async Task <IActionResult> Delete(int id, bool communityExperience = false)
        {
            try
            {
                var deletedText       = "Event";
                var requireSecretCode = await GetSiteSettingBoolAsync(
                    SiteSettingKey.Events.RequireBadge);

                if (requireSecretCode)
                {
                    var graEvent = await _eventService.GetDetails(id);

                    await _triggerService.RemoveAsync(graEvent.RelatedTriggerId.Value);

                    deletedText += " and its related trigger";
                }
                deletedText += " were successfully deleted!";
                ShowAlertSuccess(deletedText);
                await _eventService.Remove(id);
            }
            catch (GraException gex)
            {
                ShowAlertWarning("Unable to delete event: ", gex.Message);
            }

            if (communityExperience)
            {
                return(RedirectToAction("CommunityExperiences"));
            }
            else
            {
                return(RedirectToAction("Index"));
            }
        }
Esempio n. 2
0
        public async Task <IActionResult> Delete(int id)
        {
            try
            {
                var requireSecretCode = await GetSiteSettingBoolAsync(
                    SiteSettingKey.Events.RequireBadge);

                if (requireSecretCode)
                {
                    var relatedEvents = await _eventService.GetRelatedEventsForTriggerAsync(id);

                    if (relatedEvents.Any())
                    {
                        ShowAlertWarning("Unable to delete trigger: Trigger has related events");
                        return(RedirectToAction("Index"));
                    }
                }

                await _triggerService.RemoveAsync(id);

                ShowAlertSuccess("Trigger deleted.");
            }
            catch (GraException gex)
            {
                ShowAlertWarning("Unable to delete trigger: ", gex.Message);
            }
            return(RedirectToAction("Index"));
        }
Esempio n. 3
0
        public async Task <IActionResult> Delete(int id)
        {
            try
            {
                await _triggerService.RemoveAsync(id);

                ShowAlertSuccess("Trigger deleted.");
            }
            catch (GraException gex)
            {
                ShowAlertWarning("Unable to delete trigger: ", gex.Message);
            }
            return(RedirectToAction("Index"));
        }
Esempio n. 4
0
        public async Task <IActionResult> Delete(int id)
        {
            try
            {
                var requireSecretCode = await GetSiteSettingBoolAsync(
                    SiteSettingKey.Events.RequireBadge);

                if (requireSecretCode)
                {
                    var relatedEvents = await _eventService.GetRelatedEventsForTriggerAsync(id);

                    if (relatedEvents.Count > 0)
                    {
                        ShowAlertWarning("Unable to delete trigger: Trigger has related events");
                        return(RedirectToAction("Index"));
                    }
                }

                await _triggerService.RemoveAsync(id);

                ShowAlertSuccess("Trigger deleted.");
            }
            catch (GraException gex)
            {
                if (gex.Data?.Count > 0)
                {
                    var sb = new StringBuilder();
                    foreach (DictionaryEntry trigger in gex.Data)
                    {
                        sb.AppendFormat(System.Globalization.CultureInfo.InvariantCulture,
                                        "<a href=\"{0}\" target=\"_blank\">{1}</a>, ",
                                        Url.Action(nameof(TriggersController.Edit),
                                                   new { controller = TriggersController.Name, id = trigger.Key }),
                                        trigger.Value);
                    }
                    ShowAlertWarning("Unable to delete event due to these trigger(s): ",
                                     sb.ToString().Trim(' ').Trim(','));
                }
                else
                {
                    ShowAlertWarning("Unable to delete trigger: ", gex.Message);
                }
            }
            return(RedirectToAction("Index"));
        }