private void InitHandler(Object o, EventArgs e) { // Recupero il tag _loginInformation = _view.RetrieveTagInformation <ILoginInformation>("loginInformation"); string username = _loginInformation.Username; // Recupero la tipologia di utente ILoginUser user = _userRetriever(username); _authLevel = user == null ? AuthorizationLevel.GUEST : user.AuthorizationLevel; _loginName = user?.FirstName ?? " opsite"; SharedInit(); // Inizializzo in base alla tipologia di utente if (user == null || user.AuthorizationLevel == AuthorizationLevel.GUEST) { GuestInit(); } else if (user.AuthorizationLevel == AuthorizationLevel.CUSTOMER) { CustomerInit(); } else if (user.AuthorizationLevel > AuthorizationLevel.CUSTOMER) { StaffInit(); } }
private Controller() { loginInformation = new LoginInformation(); serielNumberRepository = new SerielNumberRepository(); putDownStream = new FileDownStream(); getFileUpStream = new FileUpStream(); serielNumberGenerator = new SerielNumberGenerator(); logins = new Dictionary <string, string>(); lotteryDictionary = new Dictionary <string, bool>(); submissionList = new List <Submission>(); if (getFileUpStream.isFilePresent(0).Result) { submissionList = getFileUpStream.LoadSubmissionsFromFileAsync().Result; } if (getFileUpStream.isFilePresent(1).Result) { lotteryDictionary = serielNumberRepository.SerielNumbersFromFile().Result; } if (lotteryDictionary.IsNullOrEmpty()) { Task.Run(() => lotteryDictionary = serielNumberGenerator.GenerateSerielNumberDictionary(serialsAmount)); } if (getFileUpStream.isFilePresent(2).Result) { logins = loginInformation.LoadLoginsToDictinary().Result; } if (logins.IsNullOrEmpty()) { logins.Add("admin", "admin"); } }
public static void AddLoginInformation(this Control c, ILoginInformation li) { #region Precondizioni if (li == null) { throw new ArgumentNullException("li null"); } #endregion AddTagInformation(c, "loginInformation", li); }
public LotteryController() { loginInformation = new LoginInformation(); serielNumberRepository = new SerielNumberRepository(); putDownStream = new FileDownStream(); getFileUpStream = new FileUpStream(); logins = new Dictionary <string, string>(); lotteryDictionary = new Dictionary <string, bool>(); submissionList = new List <Submission>(); submissionList = getFileUpStream.LoadSubmissionsFromFile(); loginInformation.LoadLoginsToDictinary(logins); serielNumberRepository.SerielNumbersFromFile(lotteryDictionary); }
public PrenotationCreatorPresenter(PrenotationCreatorView view) { #region Precondizioni if (view == null) { throw new ArgumentNullException("view null"); } #endregion _itemsPrenotation = new List <ICustomizableItemPrenotation>(); _bundles = new List <IBundle>(); _packets = new List <IPacket>(); _fromDateTimePicker = view.FromDateTimePicker; _toDateTimePicker = view.ToDateTimePicker; _itemPrenotationListView = view.ItemPrenotationListView; _bundleListView = view.BundleListView; _createButton = view.CreateButton; _clearButton = view.ClearButton; _packetListView = view.PacketListView; _trackingDeviceLabel = view.TrackingDeviceLabel; _customerComboBox = view.CustomerComboBox; _associateTrackingDeviceButton = view.AssociateTrackingDeviceButton; _errorProvider = view.ErrorProvider; _view = view; // init handler _clearButton.Click += ClearHandler; _view.AbortButton.Click += CancelButtonHandler; _createButton.Click += CreateButtonHandler; _fromDateTimePicker.ValueChanged += FromDateChangedHandler; _toDateTimePicker.ValueChanged += ToDateChangedHandler; _customerComboBox.SelectedIndexChanged += CustomerChangedHandler; _associateTrackingDeviceButton.Click += AddTrackingDeviceButtonHandler; _view.AddBundleButton.Click += AddBundlesButtonHandler; _view.AddPacketButton.Click += AddPacketsButtonHandler; _view.AddItemPrenotationButton.Click += AddItemPrenotationButtonHandler; // init componenti _customerComboBox.DropDownStyle = ComboBoxStyle.DropDownList; _customerComboBox.DisplayMember = "DisplayInfo"; _fromDateTimePicker.MinDate = DateTime.Now.Date; _authLevel = view.RetrieveTagInformation <AuthorizationLevel>("authorizationLevel"); if (_authLevel == AuthorizationLevel.GUEST) { throw new InvalidOperationException("Gli utenti GUEST non posso effettuare prenotazioni"); } if (_authLevel == AuthorizationLevel.CUSTOMER) { _view.CustomerLabel.Visible = false; _view.CustomerLabel.Enabled = false; _loginInfo = view.RetrieveTagInformation <ILoginInformation>("loginInformation"); _customer = (from u in _uCoord.RegisteredUsers where (u is ICustomer && u.Username.Equals(_loginInfo.Username)) select u as ICustomer).FirstOrDefault(); if (_customer == null) { MessageBox.Show("Non risultato registrato come cliente nel sistema. Chiama lo staff"); _view.Close(); } _customerComboBox.Items.Add(_customer); _customerComboBox.SelectedIndex = 0; _customerComboBox.Enabled = false; } if (_authLevel >= AuthorizationLevel.BASIC_STAFF) { _customerComboBox.Items.Clear(); foreach (ICustomer c in _uCoord.Customers) { _customerComboBox.Items.Add(c); } if (_customerComboBox.Items.Count > 0) { _customerComboBox.SelectedIndex = 0; } } _createButton.Enabled = false; _clearButton.Enabled = false; }
public UserController(ISessionFactory sessionFactory, ILoginInformation loginInformation) { _sessionFactory = sessionFactory; _loginInformation = loginInformation; }
public void Init() { _sessionFactory = new InMemorySessionFactory(); _loginInformation = Substitute.For<ILoginInformation>(); _controller = new UserController(_sessionFactory, _loginInformation); }