示例#1
0
文件: Login.cs 项目: es-dev/cantieri
 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);
     }
     
 }
示例#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);
     } 
 }
示例#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;
 }
	    /// <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();		
	    }
	    /// <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;
	    }