public FtpAccount AddAccount(string Username, string Password, bool IsSuperUser) { lock (OperationLock) { var accounts = (from account in context.FtpAccounts where account.Username == Username select account).ToList(); if (accounts.Count() > 0) return null; bool isActive = true; DateTime createDate = DateTime.Now; string md5Password = FormsAuthentication.HashPasswordForStoringInConfigFile(Password, "MD5"); FtpAccount ftpAccount = new FtpAccount { Username = Username, Password = md5Password, IsSuperUser = IsSuperUser, IsActive = isActive, CreateDate = createDate, PartitionKey = "AzureFtpAccount", RowKey = Username }; context.AddFtpAccount(ftpAccount); return ftpAccount; } }
public static void DeleteFtpAccount(FtpAccount ftpAccount) { var identity = HttpContext.Current.User.Identity; if (identity.IsAuthenticated) { var accountManager = new AccountManager(); accountManager.DeleteFtpAccount(ftpAccount.Username); } }
public void ActivateAccount(FtpAccount account) { lock (OperationLock) { if (account.IsActive == false) { account.IsActive = true; context.SaveChanges(); } } }
public static void UpdateFtpAccount(FtpAccount ftpAccount) { var identity = HttpContext.Current.User.Identity; if (identity.IsAuthenticated) { var accountManager = new AccountManager(); string Username = ftpAccount.Username; bool isActive = ftpAccount.IsActive; bool isSuperUser = identity.Name.ToLower() == AccountManager.AdminUserName ? ftpAccount.IsSuperUser : false; accountManager.UpdateFtpAccount(Username, isSuperUser, isActive); } }
public void UpdateFtpAccount(FtpAccount account) { this.UpdateObject(account); this.SaveChanges(); }
public void DeleteFtpAccount(FtpAccount account) { this.DeleteObject(account); this.SaveChanges(); }
public void AddFtpAccount(FtpAccount account) { this.AddObject("AzureFtpAccount", account); this.SaveChanges(); }