/// <summary> /// Method that generates a username for a user using their name /// </summary> /// <param name="Name">Type string, Name is the string of characters that will be used to create a username</param> /// <returns>returns a Task of type string that contains the generated username</returns> public static async Task <string> GenerateUserName(string Name) { string userNameWTag = ""; if (!string.IsNullOrEmpty(Name)) { string[] strings = Name.Split(""); string userNameBase = ""; if (strings[0].Length > 4) { userNameBase = strings[0].Substring(0, 4); } else { userNameBase = strings[0]; } userNameWTag = userNameBase + GenerateTag(); } if (await APIHandler <bool> .GetOne($"Auth/GetUserNameExists/{userNameWTag}")) { await GenerateUserName(Name); } string UserName = userNameWTag.ToLower(); return(UserName); }
/// <summary> /// Initializes all the properties that might be needed throughout the program lifecycle. /// </summary> /// <returns>Task, enables await.</returns> public static async Task InitializeAuth() { ActiveUser = await APIHandler <User> .GetOne($"Users/{UserID}"); ActiveUserRoleName = (await APIHandler <Role> .GetOne($"Roles/{ActiveUser.RoleId}")).Name; ActiveUserAccessLevel = (Constants.AccessLevels)ActiveUser.UserLevelId; ActiveUserLevelName = (await APIHandler <UserLevel> .GetOne($"UserLevels/{ActiveUser.UserLevelId}")).Name; ActiveUserStore = await APIHandler <Store> .GetOne($"Stores/{ActiveUser.StoreId}"); }
/// <summary> /// A method that updates the list of userLevels, used for editing and creating new users and assigning them a user level using the API /// </summary> /// <returns>A Task of type ObservableCollection of userLevels that is from the lowest level up to but not including the level of the logged in user</returns> public static async Task <ObservableCollection <UserLevel> > UpdateUserLevels() { AllLevels = await APIHandler <Dictionary <int, UserLevel> > .GetOne("UserLevels"); OwnerID = AllLevels.FirstOrDefault(l => l.Value.Name == "Owner").Value.Id; ObservableCollection <UserLevel> userLevels = new ObservableCollection <UserLevel>(); foreach (UserLevel uL in Data.AllLevels.Values) { if (AuthHandler.ActiveUser.UserLevelId != uL.Id) { userLevels.Add(uL); } else { break; } } return(userLevels); }
public static async Task UpdateLogs() { AllLogs = await APIHandler <List <Log> > .GetOne($"Logs/{AuthHandler.ActiveUser.Id}/{AuthHandler.SessionKey}"); }
public static async Task UpdateSuppliers() { AllSuppliers = await APIHandler <Dictionary <int, Supplier> > .GetOne("Suppliers"); }
public static async Task UpdateInvoiceHasItems() { InvoiceHasItems = await APIHandler <Dictionary <int, Dictionary <int, int> > > .GetOne("InvoicesHasItems"); }
public static async Task UpdateInvoices() { AllInvoices = await APIHandler <Dictionary <int, Invoice> > .GetOne("Invoices"); }
/// <summary> /// A method used to update the dictionary of roles using the API /// </summary> /// <returns></returns> public static async Task UpdateRoles() { AllRoles = await APIHandler <Dictionary <int, Role> > .GetOne("Roles"); }
public static async Task UpdateCategories() { AllCategories = await APIHandler <Dictionary <int, Category> > .GetOne("Categories"); }
/// <summary> /// A method used to update the dictionary of salaries using the API /// </summary> /// <returns></returns> public static async Task UpdateSalaries() { AllSalaries = await APIHandler <Dictionary <int, Salary> > .GetOne("Salaries"); }
public static async Task UpdateItemsInStocks() { ItemsInStocks = await APIHandler <Dictionary <int, Dictionary <int, int> > > .GetOne("ItemsInStocks"); }
public static async Task UpdateStockHasItems() { StockHasItems = await APIHandler <Dictionary <int, Dictionary <int, int> > > .GetOne("StockHasItems"); }
/// <summary> /// A method used to update the dictionary of users using the API /// </summary> /// <returns></returns> public static async Task UpdateUsers() { AllUsers = await APIHandler <Dictionary <int, User> > .GetOne("Users"); }
/// <summary> /// A method used to update the dictionary of stores using the API /// </summary> /// <returns></returns> public static async Task UpdateStore() { AllStores = await APIHandler <Dictionary <int, Store> > .GetOne("Stores"); }
public static async Task UpdateItems() { AllItems = await APIHandler <Dictionary <int, Item> > .GetOne("Items"); }