Exemple #1
0
        public void ProcessRequest(HttpContext context)
        {
            _context = context;

            string json = "{}";

            try
            {
                var repo = new Repository();

                List<AutoNSFW> autoNSFW = repo.GetChannelAutoNSFWList(ChannelID);
                List<Ignore> ignores = repo.GetIgnores(ChannelID);
                
                json = JsonConvert.SerializeObject(new
                {
                    success = true,

                    autoNSFW = autoNSFW
                        .Select(PlainAutoNSFW.FromModel)
                        .ToList(),

                    ignores = ignores
                        .Select(PlainIgnore.FromModel)
                        .ToList()
                });
            }
            catch (Exception ex)
            {
                json = JsonConvert.SerializeObject(new
                {
                    success = false,
                    error = "There was an error: " + ex.Message
                });
            }

            SetNoCaching(context);
            context.Response.ContentType = "text/json";
            context.Response.Write(json);
        }