Ejemplo n.º 1
0
        public static ActiveBrand Create(string brandCode)
        {
            var brand = BrandService.GetBrand(brandCode);

            // Create active user
            var activeBrand = new ActiveBrand()
            {
                BrandCode      = brand.BrandCode,
                BrandName      = brand.BrandName,
                HeadOfficeCode = brand.HoCode,
                Berthing       = brand.Berth
            };

            return(activeBrand);
        }
Ejemplo n.º 2
0
        public static ActiveUser LoadUserInfo(string login)
        {
            var key = login;

            // Load user info from database
            var user = UserService.GetUserIdentity(login);

            // Settings
            var activeSettings = new ActiveSettings
            {
                SessionTimeout = Config.Security.UserSessionTimeout,
                SessionWarning = Config.Security.UserSessionWarning,
            };

            // User
            var activeUser = new ActiveUser()
            {
                // User properties
                Login                  = user.Login,
                UserLevelCode          = user.UserLevelCode,
                UserName               = user.FirstName + " " + user.LastName,
                Email                  = user.Email,
                StoreId                = user.StoreId,
                BranchId               = user.BranchId,
                CantChangeBranch       = user.CantChangeBranch,
                BrandCode              = user.Store.BrandCode,
                HoCode                 = user.Store.Brand.HoCode,
                Settings               = activeSettings,
                DisableChangeCounselor = user.DisableCounselor
            };

            // Store
            var activeStore = new ActiveStore
            {
                StoreId          = user.StoreId,
                StoreName        = user.Store.StoreName,
                BrandCode        = user.Store.BrandCode,
                FullVersion      = user.Store.FullVersion,
                EnableBranches   = user.Store.EnableBranches,
                InvoiceStoreName = user.Store.InvoiceStoreName,
                Virtuoso         = user.Store.Virtuoso
            };

            // Brand
            var activeBrand = new ActiveBrand
            {
                BrandCode      = user.Store.BrandCode,
                BrandName      = user.Store.Brand.BrandName,
                HeadOfficeCode = user.Store.Brand.HoCode
            };

            // Head Office
            var activeHeadOffice = new ActiveHeadOffice
            {
                HeadOfficeCode = user.Store.Brand.HoCode,
                HeadOfficeName = user.Store.Brand.HeadOffice.HoName
            };

            // Head office and brand settings
            if (activeUser.IsCorporate)
            {
                // Corporate users
                if (user.UserLevelCode == Services.UserLevelCode.B)
                {
                    activeUser.BrandCode = user.CorpBrandCode;
                    activeUser.HoCode    = user.CorpBrand.HoCode;

                    // Brand
                    activeBrand = new ActiveBrand
                    {
                        BrandCode      = user.CorpBrandCode,
                        BrandName      = user.CorpBrand.BrandName,
                        HeadOfficeCode = user.CorpBrand.HoCode
                    };

                    // Head Office
                    activeHeadOffice = new ActiveHeadOffice
                    {
                        HeadOfficeCode = user.CorpBrand.HeadOffice.HoCode,
                        HeadOfficeName = user.CorpBrand.HeadOffice.HoName
                    };
                }
                else if (user.UserLevelCode == UserLevelCode.H)
                {
                    activeUser.HoCode = user.CorpHoCode;

                    // Head Office
                    activeHeadOffice = new ActiveHeadOffice
                    {
                        HeadOfficeCode = user.CorpHeadOffice.HoCode,
                        HeadOfficeName = user.CorpHeadOffice.HoName
                    };
                }
            }

            // Rights
            activeUser.Rights = new ActiveRights
            {
                CanEnterStoreNews      = user.CanEnterStoreNews,
                DisableChangeCounselor = user.DisableCounselor,
                OwnData = user.OwnData
            };

            // Reminders Filter
            activeUser.RemindersFilter = new RemindersFilter
            {
                ReminderFilterCe              = user.ReminderFilterCe,
                ReminderFilterCustomerLead    = user.ReminderFilterCustomerLead,
                ReminderFilterDateRange       = user.ReminderFilterDateRange,
                ReminderFilterDiscretionary   = user.ReminderFilterDiscretionary,
                ReminderFilterFinancial       = user.ReminderFilterFinancial,
                ReminderFilterLogin           = user.ReminderFilterLogin,
                ReminderFilterResGrp          = user.ReminderFilterResGrp,
                ReminderFilterSuppressOverdue = user.ReminderFilterSuppressOverdue
            };

            // Cache items
            CacheManager.Set($"{login}-ActiveUser", activeUser);
            CacheManager.Set($"{login}-ActiveStore", activeStore);
            CacheManager.Set($"{login}-ActiveBrand", activeBrand);
            CacheManager.Set($"{login}-ActiveHeadOffice", activeHeadOffice);

            return(activeUser);
        }