Ejemplo n.º 1
0
        /// <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);
        }
Ejemplo n.º 2
0
        /// <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}");
        }
Ejemplo n.º 3
0
        /// <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);
        }
Ejemplo n.º 4
0
 public static async Task UpdateLogs()
 {
     AllLogs = await APIHandler <List <Log> > .GetOne($"Logs/{AuthHandler.ActiveUser.Id}/{AuthHandler.SessionKey}");
 }
Ejemplo n.º 5
0
 public static async Task UpdateSuppliers()
 {
     AllSuppliers = await APIHandler <Dictionary <int, Supplier> > .GetOne("Suppliers");
 }
Ejemplo n.º 6
0
 public static async Task UpdateInvoiceHasItems()
 {
     InvoiceHasItems = await APIHandler <Dictionary <int, Dictionary <int, int> > > .GetOne("InvoicesHasItems");
 }
Ejemplo n.º 7
0
 public static async Task UpdateInvoices()
 {
     AllInvoices = await APIHandler <Dictionary <int, Invoice> > .GetOne("Invoices");
 }
Ejemplo n.º 8
0
 /// <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");
 }
Ejemplo n.º 9
0
 public static async Task UpdateCategories()
 {
     AllCategories = await APIHandler <Dictionary <int, Category> > .GetOne("Categories");
 }
Ejemplo n.º 10
0
 /// <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");
 }
Ejemplo n.º 11
0
 public static async Task UpdateItemsInStocks()
 {
     ItemsInStocks = await APIHandler <Dictionary <int, Dictionary <int, int> > > .GetOne("ItemsInStocks");
 }
Ejemplo n.º 12
0
 public static async Task UpdateStockHasItems()
 {
     StockHasItems = await APIHandler <Dictionary <int, Dictionary <int, int> > > .GetOne("StockHasItems");
 }
Ejemplo n.º 13
0
 /// <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");
 }
Ejemplo n.º 14
0
 /// <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");
 }
Ejemplo n.º 15
0
 public static async Task UpdateItems()
 {
     AllItems = await APIHandler <Dictionary <int, Item> > .GetOne("Items");
 }