Ejemplo n.º 1
0
 private void LoginApplication()
 {
     try
     {
         var username = editUsername.Text;
         var password = editPassword.Text;
         
         var account = new AccountDto(); 
         account.Username = username;
         account.Password = password;
         var viewModel = new AccountViewModel();
         var accountAuthenticated = viewModel.Authenticate(account);
         if (accountAuthenticated!=null)
         {
             SessionManager.Login(Context, accountAuthenticated);
             Context.Redirect("cantieri-homepage.aspx");
         }
         else
         {
             lblLoginFault.Visible = true;
         }
     }
     catch (Exception ex)
     {
         UtilityError.Write(ex);
     }
     
 }
Ejemplo n.º 2
0
 internal static void Login(IContext context, AccountDto account)
 {
     try
     {
         context.Session["account"] = account; 
         context.Session.IsLoggedOn = true;
     }
     catch (Exception ex)
     {
         UtilityError.Write(ex);
     } 
 }
Ejemplo n.º 3
0
 public static string GetCodifica(AccountDto account)
 {
     try
     {
         if(account!=null)
         {
             var codifica = account.Nickname + " - " + account.Ruolo;
             return codifica;
         }
     }
     catch (Exception ex)
     {
         UtilityError.Write(ex);
     }
     return null;
 }
Ejemplo n.º 4
0
	    /// <summary>
	    /// Deletes account from the database by the given dto object.
	    /// </summary>
	    /// <param name="account">The dto object.</param>
	    public void DeleteAccount(AccountDto account)
	    {
	        this.AccountService.Delete(account);
	        this.UnitOfWork.SaveChanges();		
	    }
Ejemplo n.º 5
0
	    /// <summary>
	    /// Adds a new account from the given dto object into the database.
	    /// </summary>
	    /// <param name="account">The dto object.</param>
	    /// <returns>The dto key of the newly created account.</returns>
	    public string CreateAccount(AccountDto account)
	    {
	        string key = this.AccountService.Add(account);
	        this.UnitOfWork.SaveChanges();
	        return key;
	    }