Exemplo n.º 1
0
 protected void StoreUserSettings(UserSettingsModel userSettings)
 {
     Session[UserSettingsKey] = userSettings;
 }
Exemplo n.º 2
0
        protected UserSettingsModel RetreiveUserSettingsModel()
        {
            if (!Request.IsAuthenticated)
            {
                return null;
            }

            UserSettingsModel userSettings = new UserSettingsModel();

            string userLogin = GetCurrentUserLogin();

            var user = (from u in PrdnDBContext.Users.Include("PrdnSettings.DefaultRun")
                        where u.Login == userLogin
                        select u).FirstOrDefault();

            if (user != null)
            {
                userSettings.UserID = user.ID;
                userSettings.Login = user.Login;

                if (user.PrdnSettings != null)
                {
                    userSettings.JobPageSize = (user.PrdnSettings.JobPageSize == null) ? UserSettingsModel.DefaultPageSize : Convert.ToInt32(user.PrdnSettings.JobPageSize);
                    userSettings.RequestPageSize = (user.PrdnSettings.RequestPageSize == null) ? UserSettingsModel.DefaultPageSize : Convert.ToInt32(user.PrdnSettings.RequestPageSize);
                    userSettings.LabelPrinterID = (user.PrdnSettings.LabelPrinterID == null) ? (int?)null : Convert.ToInt32(user.PrdnSettings.LabelPrinterID);

                    if (user.PrdnSettings.DefaultRun != null)
                    {
                        userSettings.DefaultRunOrderNo = user.PrdnSettings.DefaultRun.PrdnOrderNo;
                        userSettings.DefaultRunID = user.PrdnSettings.DefaultRun.ID;
                        userSettings.DefaultRunDescr = user.PrdnSettings.DefaultRun.RunDescr;
                    }
                }
            }
            else
            {
                throw new Exception("Invalid User Login");
            }

            return userSettings;
        }