Esempio n. 1
0
        public HttpResponseMessage LogInRequest(Account model)
        {
            var    dbManager = new Backend.Managers.DatabaseManager();
            String hashed    = GenerateSHA256String(model.Password);

            if (dbManager.Authenticate(model.Username, hashed).Result == true)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, model.Username + "Log In Successful."));
            }
            else
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Log In Not Successful. " + dbManager.Authenticate(model.Username, hashed).Result));
            }
        }
Esempio n. 2
0
        public HttpResponseMessage TableInfo(string search)
        {
            var dbManager = new Backend.Managers.DatabaseManager();

            if (search == "part")
            {
                currentTable = dbManager.GetInventoryTable().Result;
                var tableObjects = new List <object>();
                var skus         = new Dictionary <string, object>();
                for (int i = 0; i < currentTable.PartsData.Length; i++)
                {
                    if (skus.TryGetValue(currentTable.PartsData[i].SKU as string, out var part))
                    {
                        ((Backend.Models.Part)part).count++;
                        skus.Remove(currentTable.PartsData[i].SKU);
                        skus.Add(currentTable.PartsData[i].SKU, part);
                    }
                    else
                    {
                        skus.Add(currentTable.PartsData[i].SKU,
                                 new Backend.Models.Part
                        {
                            name     = currentTable.PartsData[i].name,
                            count    = currentTable.PartsData[i].count,
                            itemType = currentTable.PartsData[i].itemType,
                            SKU      = currentTable.PartsData[i].SKU
                        });
                    }
                }

                for (int i = 0; i < currentTable.SystemsData.Length; i++)
                {
                    if (skus.TryGetValue(currentTable.SystemsData[i].SKU as string, out var system))
                    {
                        ((Backend.Models.System)system).count++;
                        skus.Remove(currentTable.SystemsData[i].SKU);
                        skus.Add(currentTable.SystemsData[i].SKU, system);
                    }
                    else
                    {
                        skus.Add(currentTable.SystemsData[i].SKU,
                                 new Backend.Models.System
                        {
                            name     = currentTable.SystemsData[i].name,
                            count    = currentTable.SystemsData[i].count,
                            itemType = currentTable.SystemsData[i].itemType,
                            SKU      = currentTable.SystemsData[i].SKU
                        });
                    }
                }

                foreach (KeyValuePair <string, object> pair in skus)
                {
                    tableObjects.Add(pair.Value);
                }

                var b = new TableInfo
                {
                    Headers = new[] { "name", "SKU", "count", "itemType" },
                    Data    = tableObjects.ToArray()
                };
                return(Request.CreateResponse(HttpStatusCode.OK, b));
            }
            else if (search == "partSystem")
            {
                return(Request.CreateResponse(HttpStatusCode.OK, dbManager.GetSystemsTable()));
            }
            else if (search == "systemEdit")
            {
                return(Request.CreateResponse(HttpStatusCode.OK, dbManager.GetPartsTable()));
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }
        }
        public HttpResponseMessage TableInfo(string search)
        {
            var dbManager = new Backend.Managers.DatabaseManager();

            return(Request.CreateResponse(HttpStatusCode.OK, dbManager.GetEquipmentTable()));
        }