/// <summary>
 /// Occurs when presentation settings are updated.
 /// </summary>
 /// <param name="team">Team name.</param>
 /// <param name="userId">Id of the owner of the edit.</param>
 /// <param name="slides">Settings.</param>
 public void OnSettingsUpdated(string team, int userId, PresentationSettingsModel settings)
 {
     Clients.Group(team).onSettingsUpdated(userId, settings, GetCollaborators(team));
 }
        public PresentationUpdateResultModel UpdateSettings([FromBody] PresentationSettingsModel settings, int?id = null)
        {
            Slide        s           = null;
            bool         isNew       = true;
            Presentation p           = null;
            User         currentUser = null;

            if (settings != null)
            {
                isNew = !id.HasValue;
                p     = isNew ? new Presentation() : Get(id.Value);

                if (p != null)
                {
                    p.Title           = settings.Title;
                    p.Theme           = settings.Theme;
                    p.BackgroundImage = settings.BackgroundImage;

                    currentUser = ApplicationContext.Current.User;

                    if (p.UserId <= 0)
                    {
                        p.UserId = currentUser.Id;
                    }

                    if (currentUser.Subscription != null)
                    {
                        // If the presentation is new OR if the user's subscription is "better" than is currently saved under the presentation - updating.
                        if (isNew || (int)p.UserSubscriptionType < (int)currentUser.Subscription.Type)
                        {
                            p.UserSubscriptionType = currentUser.Subscription.Type;
                        }
                    }
                    else if (isNew)
                    {
                        p.UserSubscriptionType = SubscriptionType.Basic;
                    }

                    if (isNew)
                    {
                        // New presentations automatically get Google Charts as chart provider.
                        p.UseCharts = PresentationChartProviderType.GoogleCharts;

                        // New presentations will not have "Slide description" functionality.
                        p.UseSlideDescription = PresentationSlideDescriptionType.Never;

                        // For new presentations, adding new slide automatically.
                        p.Slides.Add(s = new Slide()
                        {
                            Title = Ifly.Resources.Editor.Slide1
                        });
                    }

                    p = base.Service.CreateOrUpdate(p);
                }
            }

            return(new PresentationUpdateResultModel {
                Id = p.Id, Slide = s
            });
        }