public async Task <ActionResult> OnPostSend(string emailAddress) { Result result; try { SubscriberModel subscriber = await Data.Item(SiteSettings.Site, Area.Blog, emailAddress); if (subscriber == null) { throw new NullReferenceException($"No subscriber found for {emailAddress}."); } result = await Data.Delete(SiteSettings.Site, subscriber.Id); if (result.Status == ResultStatus.Failed) { return(new JsonResult(result)); } result = new Result(ResultStatus.Succeeded, $"{emailAddress} has been unsubscribed.", Guid.Empty); } catch (Exception ex) { result = new Result(ResultStatus.Failed, ex.Message, Guid.Empty); } return(new JsonResult(result)); }
public async Task <ActionResult> OnPostDeleteSubscriber(string emailAddress) { Result result; try { result = await Data.Delete(SiteSettings.Site, emailAddress); if (result.Status == ResultStatus.Succeeded) { result = new Result(ResultStatus.Succeeded, $"{emailAddress} has been unsubscribed.", Guid.Empty); } } catch (System.Exception ex) { result = new Result(ResultStatus.Failed, ex.Message, Guid.Empty); } return(new JsonResult(result)); }