Beispiel #1
0
        internal void UpdateSubscriptions(Models.Settings.Device.Subscription theUpdatedSubscriptions)
        {
            bool SubChangesMade = false;

            BBSubscription Subscription = null;

            bool CreateNew = string.Equals(theUpdatedSubscriptions.SubscriptionGuid, "new", System.StringComparison.OrdinalIgnoreCase);

            BBOutput OutputSearch = null;

            OutputSearch = Outputs.FirstOrDefault(o => o.Name == theUpdatedSubscriptions.OutputId);

            if (OutputSearch != null && !CreateNew)
            {
                Subscription = OutputSearch.Subscriptions.FirstOrDefault(s => s.Guid == theUpdatedSubscriptions.SubscriptionGuid);
            }

            if (CreateNew && OutputSearch != null)
            {
                OutputSearch.Add(theUpdatedSubscriptions.SubscriptionId, new BBSubscriptionProperties
                {
                    HighSubject = theUpdatedSubscriptions.HighKey,
                    HighValue   = theUpdatedSubscriptions.HighValue,
                    LowSubject  = theUpdatedSubscriptions.LowKey,
                    LowValue    = theUpdatedSubscriptions.LowValue
                });

                SubChangesMade = true;
            }
            else
            {
                if (Subscription != null)
                {
                    if (Subscription.Id != theUpdatedSubscriptions.SubscriptionId)
                    {
                        SubChangesMade  = true;
                        Subscription.Id = theUpdatedSubscriptions.SubscriptionId;
                    }


                    Subscription.Update(new BBSubscriptionProperties
                    {
                        HighSubject = theUpdatedSubscriptions.HighKey,
                        HighValue   = theUpdatedSubscriptions.HighValue,
                        LowSubject  = theUpdatedSubscriptions.LowKey,
                        LowValue    = theUpdatedSubscriptions.LowValue
                    });
                }
            }

            if (SubChangesMade)
            {
                ConstructSubscriptions();
            }
        }
Beispiel #2
0
        public Response Post(Models.Settings.Device.Subscription theModel)
        {
            Core.Instance.Update(theModel);

            var HomePage = Context.Referrer.AbsoluteUri;

            HomePage = HomePage.Remove(HomePage.LastIndexOf("subscription/"));
            HomePage = HomePage + "device/?id=" + theModel.DeviceId;

            return(new Response
            {
                StatusCode = System.Net.HttpStatusCode.Moved,
                Location = new System.Uri(HomePage)
            });
        }