Inheritance: IdentifiedEntity
        private SelectServiceButton[] CreateControlsForGroupsAndSituations(LifeSituationGroup[] groups, LifeSituation[] services)
        {
            var buttons = new List<SelectServiceButton>();
            if (groups != null)
            {
                foreach (var group in groups.Where(g => g.IsActive))
                {
                    buttons.Add(CreateSelectServiceButton(group.Code, group.Name, group.Color, group.FontSize, (s, a) => OnServiceGroupSelected(group)));
                }
            }
            if (services != null)
            {
                foreach (var service in services.Where(s => s.IsActive))
                {
                    buttons.Add(CreateSelectServiceButton(service.Code,
                                                        service.Name,
                                                        service.GetColor(),
                                                        service.FontSize,
                                                        (s, a) => SetSelectedLifeSituation(service)
                    ));
                }
            }

            return buttons.ToArray();
        }
        private async void saveButton_Click(object sender, EventArgs e)
        {
            using (var channel = ChannelManager.CreateChannel())
            {
                try
                {
                    saveButton.Enabled = false;

                    LifeSituation = await taskPool.AddTask(channel.Service.EditLifeSituation(lifeSituation));
                    if (Saved != null)
                    {
                        Saved(this, EventArgs.Empty);
                    }
                }
                catch (OperationCanceledException) { }
                catch (CommunicationObjectAbortedException) { }
                catch (ObjectDisposedException) { }
                catch (InvalidOperationException) { }
                catch (FaultException exception)
                {
                    UIHelper.Warning(exception.Reason.ToString());
                }
                catch (Exception exception)
                {
                    UIHelper.Warning(exception.Message);
                }
                finally
                {
                    saveButton.Enabled = true;
                }
            }
        }
        private async void EditLifeSituationForm_Load(object sender, EventArgs e)
        {
            using (var channel = ChannelManager.CreateChannel())
            {
                try
                {
                    Enabled = false;

                    if (groupId != Guid.Empty)
                    {
                        group = await taskPool.AddTask(channel.Service.GetGroup(groupId));
                    }

                    if (lifeSituationId != Guid.Empty)
                    {
                        LifeSituation = await taskPool.AddTask(channel.Service.GetLifeSituation(lifeSituationId));
                    }
                    else
                    {
                        LifeSituation = new LifeSituation()
                        {
                            IsActive = true,
                            LifeSituationGroup = group,
                            Code = "0.0",
                            Name = "Новая жизненная ситуация",
                            Color = "#FFFFFF",
                            FontSize = 1
                        };
                    }

                    Enabled = true;
                }
                catch (OperationCanceledException) { }
                catch (CommunicationObjectAbortedException) { }
                catch (ObjectDisposedException) { }
                catch (InvalidOperationException) { }
                catch (FaultException exception)
                {
                    UIHelper.Warning(exception.Reason.ToString());
                }
                catch (Exception exception)
                {
                    UIHelper.Warning(exception.Message);
                }
            }
        }
 private void SetSelectedLifeSituation(LifeSituation situation)
 {
     OnServiceSelected(this, situation.Service);
 }
 private void AddSituationsToButtons(LifeSituation[] services, List<SelectServiceButton> buttons)
 {
     foreach (var service in services.Where(s => s.IsActive))
     {
         buttons.Add(CreateSelectServiceButton(service.Code,
                                             service.Name,
                                             service.GetColor(),
                                             service.FontSize,
                                             (s, a) => SetSelectedLifeSituation(service)
         ));
     }
 }