Exemple #1
0
        private static HttpResponseMessage TryListSubscriptions(string mail)
        {
            using SqlConnection conn = ConnectionFactory.CreateConnection();
            conn.Open();

            if (!DbUtilities.SubscriberExists(conn, mail))
            {
                return(new HttpResponseMessage(HttpStatusCode.BadRequest));
            }

            List <SubscriptionToList> subscribedSets = DbUtilities.GetActiveSubscriptionsOfUser(conn, mail);
            var json = JsonConvert.SerializeObject(new { subscriptions = subscribedSets }, Formatting.Indented);

            return(new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(json, Encoding.UTF8, "application/json")
            });
        }