public string Add(string name, int order)
        {
            var db = DbGrocery;
            var grocery = new Grocery
            {
                Id = Guid.NewGuid().ToString(),
                Name = name,
                Order = order,
                Done = false
            };

            db.Add(grocery);
            DbGrocery = db;

            return grocery.Id;
        }
        //Method for Analyzing the Grocery Stores. Food Inspection and Building Violations File
        public FinalAnalysis[] analysisGroceryFood(Grocery[] groceryData, FoodInspection[] foodInspectionData, BuildingViolation[] buildingInspectionData, ref int n)
        {
            int c = 0;
            long m = 0;
            DateTime maxDate = DateTime.MinValue;
            // Analysis between Grocery Stores and Food Inspection
            for (long k = 0; k < groceryStoreCnt; k++)
            {
                bool isInspcted = false;
                c = 0;
                maxDate = DateTime.MinValue;
                for (m = 0; m < foodInspectionCnt; m++)
                {

                    //comparing the license ID of grocery stores with the stores in food inspections data
                    if (string.Compare(groceryData[k].licenseID, foodInspectionData[m].storeLicenseID) == 0)
                    {
                        isInspcted = true;
                        record_match[c].licenseID = groceryData[k].licenseID;
                        record_match[c].date = Convert.ToDateTime(foodInspectionData[m].inspectionDate);
                        record_match[c].status = foodInspectionData[m].foodInspectionStatus;
                        c++;
                    }

                }

                // populating the grocery stores that are not matched (not been inspected)
                if (!isInspcted)
                {
                    finalAnalysis[n].storeInspectionStatus = "NOT INSPECTED";
                    finalAnalysis[n].storeName = groceryData[k].storeName;
                    finalAnalysis[n].storeLicenceID = groceryData[k].licenseID;
                    finalAnalysis[n].addressFailedGrocery = groceryData[k].groceryAddress;

                    // populating the grocery stores not inspected and having building violations
                    for (int g = 0; g < bldg_num; g++)
                    {

                        //comparing grocery store address with building address to check for violation
                        if (string.Compare(finalAnalysis[n].addressFailedGrocery, buildingData[g].buildingAddress) == 0)
                        {
                            finalAnalysis[n].violation = buildingData[g].violation;
                            break;
                        }
                        else
                        {
                            finalAnalysis[n].violation = "No Building Violation";
                        }
                    }
                    n++;
                }

                // Considering the latest (max) inspection date for all the matched records
                if (isInspcted)
                {
                    foreach (var r in record_match)
                    {
                        if (maxDate < r.date)
                        {
                            maxDate = r.date;
                        }
                    }

                    // considering only failed inpsection records
                    for (int q = 0; q < record_match.Length; q++)
                    {
                        if (record_match[q].date == maxDate)
                        {

                            // Comparing the status to find only the failed records
                            if (record_match[q].status != null && string.Compare(record_match[q].status.ToUpper(), "FAIL") == 0)
                            {
                                finalAnalysis[n].storeInspectionStatus = record_match[q].status;
                                finalAnalysis[n].storeName = groceryData[k].storeName;
                                finalAnalysis[n].storeLicenceID = record_match[q].licenseID;
                                finalAnalysis[n].addressFailedGrocery = groceryData[k].groceryAddress;

                                // populating the grocery stores that have failed food inspection and have building violations
                                for (int g = 0; g < bldg_num; g++)
                                {

                                    //comparing grocery store address with building address to check for violation
                                    if (string.Compare(finalAnalysis[n].addressFailedGrocery, buildingData[g].buildingAddress) == 0)
                                    {
                                        finalAnalysis[n].violation = buildingData[g].violation;
                                        break;
                                    }
                                    else
                                    {
                                        finalAnalysis[n].violation = "No Building Violation";
                                    }
                                }
                                n++;
                            }
                        }
                    }

                    // Clearing the temporary records for next iteration
                    for (int u = 0; u < record_match.Length; u++)
                    {
                        record_match[u].date = DateTime.MinValue;
                        record_match[u].licenseID = null;
                        record_match[u].status = null;
                    }
                }

            }

            return finalAnalysis;
        }
Exemplo n.º 3
0
 private bool CheckIfIsAvailable(Grocery grocery)
 {
     return(ChamberOfSecrets.Instance.@group.AvailableGroceries.Groceries.Exists
                (x => x.Name == grocery.Name && x.Amount >= grocery.Amount));
 }
Exemplo n.º 4
0
 public void UpdateGrocery(Grocery gcy)
 {
 }
Exemplo n.º 5
0
 public void AddGrocery(Grocery grocery)
 {
     _appDbContext.Groceries.Add(grocery);
     _appDbContext.SaveChanges();
 }
Exemplo n.º 6
0
 public void Post([FromBody] Grocery g)
 {
     _con.Groceries.Add(g);
     _con.SaveChanges();
 }
Exemplo n.º 7
0
        public Grocery Get(int id)
        {
            Grocery x = _con.Groceries.Where(c => c.ItemId == id).FirstOrDefault();

            return(x);
        }