Exemplo n.º 1
0
		public MainWindow(SessionInfo sessionInfo)
		{
			this.DataContext = sessionInfo;
			
			#region Command bindings
			//New command binding
			CommandBinding newCommandBinding = new CommandBinding(InvoiceManagerCommands.New);
			newCommandBinding.Executed += NewCommand_Executed;
			newCommandBinding.CanExecute += NewCommand_CanExecute;
			CommandBindings.Add(newCommandBinding);
			//Edit command binding
			CommandBinding editCommandBinding = new CommandBinding(InvoiceManagerCommands.Edit);
			editCommandBinding.Executed += EditCommand_Executed;
			editCommandBinding.CanExecute += EditCommand_CanExecute;
			CommandBindings.Add(editCommandBinding);
			//Delete command binding
			CommandBinding deleteCommandBinding = new CommandBinding(InvoiceManagerCommands.Delete);
			deleteCommandBinding.Executed += DeleteCommand_Executed;
			deleteCommandBinding.CanExecute += DeleteCommand_CanExecute;
			CommandBindings.Add(deleteCommandBinding);
			#endregion
			
			InitializeComponent();
			App.Current.MainWindow = this;
		}
Exemplo n.º 2
0
		/// <summary>
		/// Checks the user's username and password in the database; If a user is found the Currentuser and CurrentRole are set.
		/// </summary>
		public static bool AuthenticateUser(string username, string password)
		{
			try
			{
				_currentSessionInfo = new SessionInfo();
				IRepository<User> userRepository = RepositoryFactory<User>.Initialize();
				CurrentSessionInfo.CurrentUser = userRepository.Retrieve(username);
				if (CurrentSessionInfo.CurrentUser.PASSWORD == CalculateSHA1(password))
				{
					Logger.Log("Вход в системата.");
					return true;
				}
				else 
				{
					_currentSessionInfo = null;
					return false;
				}
			}
			catch (InvalidOperationException)
			{
				_currentSessionInfo = null;
				return false;
			}
		}
Exemplo n.º 3
0
		/// <summary>
		/// Nullifies the CurrentSessionInfo and logs it.
		/// </summary>
		public static void DeAuthenticateUser()
		{
			Logger.Log("Изход от системата.");
			_currentSessionInfo = null;
		}