public virtual void ApplySettingsTemplate(DrugstoreSettings settings)
 {
     if (Id == 921)
     {
         settings.SendWaybillsFromClient = true;
     }
 }
        public void Setup()
        {
            client   = DataMother.CreateTestClientWithUser();
            settings = client.Settings;

            Open(client, "Settings");
            AssertText("Конфигурация клиента");
        }
        public void Setup()
        {
            client   = DataMother.CreateTestClientWithUser();
            settings = client.Settings;
            user     = client.Users.First();

            Open(client);
            AssertText("Клиент");
        }
        public void UpdateDrugstore(
            [ARDataBind("client", AutoLoad = AutoLoadBehavior.Always)] Client client,
            [ARDataBind("drugstore.SmartOrderRules", AutoLoad = AutoLoadBehavior.NullIfInvalidKey)] SmartOrderRules smartOrderRules,
            [ARDataBind("drugstore", AutoLoad = AutoLoadBehavior.NullIfInvalidKey, Expect = "drugstore.OfferMatrixExcludes")] DrugstoreSettings drugstore,
            [DataBind("regionSettings")] RegionSettings[] regionSettings, [DataBind("markupsSynchronization")] MarkupsSynchronizationView markupsSynchronization,
            ulong homeRegion)
        {
            Admin.CheckClientPermission(client);

            if (Form["ResetReclameDate"] != null)
            {
                new ResetReclameDate(client).Execute(DbSession);
                Notify("Сброшена");
                RedirectTo(client);
                return;
            }

            var oldMaskRegion = client.MaskRegion;

            client.HomeRegion = DbSession.Load <Region>(homeRegion);
            client.UpdateRegionSettings(regionSettings);
            if (!IsValid(client))
            {
                Settings(client.Id);
                PropertyBag["client"] = client;
                RenderView("Settings");
                return;
            }

            if (drugstore.EnableSmartOrder)
            {
                if (drugstore.SmartOrderRules == null && smartOrderRules == null)
                {
                    drugstore.SmartOrderRules = new SmartOrderRules();
                    BindObjectInstance(drugstore.SmartOrderRules, "drugstore.SmartOrderRules", AutoLoadBehavior.NewRootInstanceIfInvalidKey);
                }
                else
                {
                    drugstore.SmartOrderRules = smartOrderRules;
                }
            }
            if (drugstore.IsChanged(d => d.IgnoreNewPrices) && !drugstore.IgnoreNewPrices)
            {
                client.UpdatePricesForClient(DbSession);
                Warning("Вы сняли опцию \"Не подключать новые прайсы 'Административно'\", целесообразно отправить всем поставщикам повторное уведомление о регистрации. Данные сохранены.");
            }
            drugstore.BeforeSave();

            markupsSynchronization.UpdateSynchronizationIfNeeds(DbSession, client)?.ForEach(s => {
                DbSession.Save(s);
                var audit = new AuditRecord(client)
                {
                    ObjectId    = s.Id,
                    IsHtml      = true,
                    Name        = MarkupGlobalConfig.GetTypeDescription(s.Type),
                    MessageType = LogMessageType.System,
                    Message     = $"<strong>Добавлены</strong> 'настройки наценок': <br/>{s.GetLogState()}"
                };
                DbSession.Save(audit);
            });
            DbSession.Save(client);

            DbSession.Save(drugstore);
            DbSession.Flush();
            if (oldMaskRegion != client.MaskRegion)
            {
                client.MaintainIntersection(DbSession);
            }

            Notify("Сохранено");
            RedirectTo(client);
        }