/// <summary>
 /// Gets the accounts.
 /// </summary>
 /// <returns></returns>
 public override AccountViewItem[] GetAccounts()
 {
     return(MobiGuiderRepositoryAgentFactory
            .CreateAccountRepositoryAgent()
            .SelectAll()
            .Select(CreateAccountViewItem)
            .ToArray());
 }
 /// <summary>
 /// Creates the account.
 /// </summary>
 /// <param name="acc">The acc.</param>
 private static void SaveAccount(Account acc)
 {
     if (!AccountExists(acc))
     {
         MobiGuiderRepositoryAgentFactory
         .CreateAccountRepositoryAgent()
         .Insert(acc);
     }
     else
     {
         MobiGuiderRepositoryAgentFactory
         .CreateAccountRepositoryAgent()
         .Update(acc);
     }
 }
        /// <summary>
        /// Logins the user.
        /// </summary>
        /// <param name="userName">Name of the user.</param>
        /// <param name="userPassword">The user password.</param>
        /// <returns></returns>
        public override LogonResponse LoginUser(string userName, string passWord)
        {
            Account[] res = MobiGuiderRepositoryAgentFactory
                            .CreateAccountRepositoryAgent()
                            .SelectByUsernamePassword(userName, passWord);
            string sid = Guid.NewGuid().ToString();

            return(new LogonResponse()
            {
                IsAuthenticated = (res != null),
                SessionId = sid,
                Session = new PMSSession()
                {
                    ConnectionTime = DateTime.Now,
                    AccountId = (res != null) ? res[0].Id : AccountDefaults.Id,
                    SessionId = (res != null) ? sid : AccountDefaults.SessionId,
                    Username = (res != null) ? res[0].Username : AccountDefaults.UserName
                }
            });
        }
 /// <summary>
 /// Accounts the exists.
 /// </summary>
 /// <param name="acc">The acc.</param>
 /// <returns></returns>
 private static bool AccountExists(Account acc)
 {
     return(MobiGuiderRepositoryAgentFactory
            .CreateAccountRepositoryAgent()
            .SelectById(acc.Id) != null);
 }