static void CreateNewStaffAccountUsingUserAccount() { //Create new account string username = "******"; string password = UserAccount.stringToHashString("testStaffUser"); bool isAnalyticsAllowed = true; bool isEditTablesAllowed = true; bool isAddDeliveryAllowed = true; UserAccount staff = StaffAccount.GetNewStaffAccount(username, password, isAnalyticsAllowed, isEditTablesAllowed, isAddDeliveryAllowed); //Commit to db using (var dbContext = new InventoryContext()) { try { dbContext.UserAccounts.Add(staff); dbContext.SaveChanges(); //Did work Console.WriteLine("It worked"); } catch (Exception ex) { //Didn't work Console.WriteLine(ex.ToString()); } } }
static UserAccount GetNewAccount(string username, string password, bool isAdmin, bool isAnalyticsAllowed, bool isEditTablesAllowed, bool isAddDeliveryAllowed) { if (isAdmin) { return(AdminAccount.CreateNewAdminAccount(username, password)); } else { return(StaffAccount.GetNewStaffAccount(username, password, isAnalyticsAllowed, isEditTablesAllowed, isAddDeliveryAllowed)); } }