using System;
using [Link];
using [Link];
using [Link].X509Certificates;
using [Link];
using [Link];
//using [Link];
namespace ICT711_Day5_classes
{
public class Store : IStore
{
public string StoreName { get; set; }
public string Address { get; set; }
[JsonIgnore] // Don't store this data inside the store file. Will be stored in a separate file
public List<ICustomer> Customers { get; set; }
[JsonIgnore] // Don't store this data inside the store file. Will be stored in a separate file
public List<IAssociate> Associates { get; set; }
[JsonIgnore] // Don't store this data inside the store file. Will be stored in a separate file
public Inventory Inventory { get; set; }
[JsonIgnore] // Don't store this data inside the store file. Will be stored in a separate file
public List<ISale> Sales { get; set; }
[JsonProperty]
public static string AssociatesFileName { get; set; } = "[Link]";
[JsonProperty]
public static string CustomersFileName { get; set; } = "[Link]";
[JsonProperty]
public static string InventoryFileName { get; set; } = "[Link]";
[JsonProperty]
public static string SalesFileName { get; set; } = "[Link]";
public static string StoreFileName { get; set; } = "[Link]";
public Store()
{
[Link] = "New Store Name"; //JEN: Added
[Link] = "Somewhere address"; //JEN: Added
}
public void LoadAssociates()
{
if ()
{
Associates = new List<Associate>().ConvertAll(a => (IAssociate)a);
}
string jsonString = [Link](AssociatesFileName);
var ass = [Link]<List<Associate>>(jsonString, new JsonSerializerSettings
{
TypeNameHandling = [Link]
});
Associates = [Link](c => (IAssociate)c); // Typecasting for each element
//return;
// throw new NotImplementedException();
public void LoadCustomers()
{
if()
{
Customers = new List<Customer>().ConvertAll(a => (ICustomer)a);
return;
}
string jsonString = [Link](CustomersFileName);
var cs = [Link]<List<Customer>>(jsonString, new JsonSerializerSettings
{
TypeNameHandling = [Link]
});
Customers = [Link](c => (ICustomer)c);
// return;
// throw new NotImplementedException();
}
public void LoadInventory()
{
if ()
{
Inventory = new Inventory();
return;
}
string jsonString = [Link](InventoryFileName);
var settings = new JsonSerializerSettings
{
TypeNameHandling = [Link]
};
Inventory = [Link]<Inventory>(jsonString, settings);
}
public void LoadSales()
{
if ()
{
Sales = new List<ISale>(); // Initialize an empty list if the sales file does not exist.
return;
}
string jsonString = [Link](SalesFileName);
var settings = new JsonSerializerSettings
{
TypeNameHandling = [Link]
};
Sales = [Link]<List<ISale>>(jsonString, settings);
}
public void SaveAssociates()
{
string jsonString = [Link](Associates, [Link], new JsonSerializerSettings
{
TypeNameHandling = [Link]
});
[Link](AssociatesFileName, jsonString);
return;
//throw new NotImplementedException();
}
public void SaveCustomers()
{
string jsonString = [Link](Customers, [Link], new JsonSerializerSettings
{
TypeNameHandling = [Link]
});
[Link](CustomersFileName, jsonString);
return;
}
public void SaveInventory()
{
string jsonString = [Link](Inventory, [Link], new JsonSerializerSettings
{
TypeNameHandling = [Link]
});
[Link](InventoryFileName, jsonString);
return;
}
public void SaveSales()
{
string jsonString = [Link](Sales, [Link], new JsonSerializerSettings
{
TypeNameHandling = [Link]
});
[Link](SalesFileName, jsonString);
return;
}
public void SaveStoreInfo(string StoreDataFileName = null)
{
Dictionary<string, string> StoreDetails = new Dictionary<string, string>();
StoreDetails[StoreName] = Address;
string jsonString = [Link](StoreDetails, [Link], new JsonSerializerSettings
{
TypeNameHandling = [Link]
});
[Link]("[Link]", jsonString);
public static Store CreateStore() // Factory method
{
if () // in case no file exists
{
return new Store();
}
string jsonString = [Link](StoreFileName);
return [Link]<Store>(jsonString, new JsonSerializerSettings
{
TypeNameHandling = [Link]
});
}
}
}