saki
saki
CC#
Created by saki on 6/20/2023 in #help
❔ Sum quantity in a list by name value?
You overestimate how much I know about this language right now xD
28 replies
CC#
Created by saki on 6/20/2023 in #help
❔ Sum quantity in a list by name value?
This also lets me know that I need to learn more about dictionaries
28 replies
CC#
Created by saki on 6/20/2023 in #help
❔ Sum quantity in a list by name value?
Tysm <3
28 replies
CC#
Created by saki on 6/20/2023 in #help
❔ Sum quantity in a list by name value?
I got it
28 replies
CC#
Created by saki on 6/20/2023 in #help
❔ Sum quantity in a list by name value?
I think Linq might be messing with it?
28 replies
CC#
Created by saki on 6/20/2023 in #help
❔ Sum quantity in a list by name value?
28 replies
CC#
Created by saki on 6/20/2023 in #help
❔ Sum quantity in a list by name value?
Cannot implicity cast I think?
28 replies
CC#
Created by saki on 6/20/2023 in #help
❔ Sum quantity in a list by name value?
Nah not that
28 replies
CC#
Created by saki on 6/20/2023 in #help
❔ Sum quantity in a list by name value?
Still an error and idk if this is me being stupid
28 replies
CC#
Created by saki on 6/20/2023 in #help
❔ Sum quantity in a list by name value?
AAAAAAAA
28 replies
CC#
Created by saki on 6/20/2023 in #help
❔ Sum quantity in a list by name value?
Dw it would have taken me ages to figure that out
28 replies
CC#
Created by saki on 6/20/2023 in #help
❔ Sum quantity in a list by name value?
That seemed to have made an error
28 replies
CC#
Created by saki on 6/20/2023 in #help
❔ Sum quantity in a list by name value?
uhhh
28 replies
CC#
Created by saki on 6/20/2023 in #help
❔ Sum quantity in a list by name value?
This is proof of how much my C# sucks hehe
28 replies
CC#
Created by saki on 6/20/2023 in #help
❔ Sum quantity in a list by name value?
Oooh man
28 replies
CC#
Created by saki on 6/20/2023 in #help
❔ Sum quantity in a list by name value?
public class OrderData
{
private static string format = "dd.MM.yyyy";
private static IsoDateTimeConverter converter = new IsoDateTimeConverter { DateTimeFormat = format };

private static string orderJson = File.ReadAllText("data/Orders.json");
private static string productJson = File.ReadAllText("data/Products.json");
private static string joiningJson = File.ReadAllText("data/OrderProducts.json");

private static List<Order> Orders = JsonConvert.DeserializeObject<List<Order>>(orderJson, converter);
private static List<Product> Products = JsonConvert.DeserializeObject<List<Product>>(productJson);
private static List<OrderProduct> Joining = JsonConvert.DeserializeObject<List<OrderProduct>>(joiningJson);

public static List<RecentOrder> RecentOrders = new List<RecentOrder> (from joining in Joining
join orders in Orders on joining.OrderID equals orders.OrderID
join products in Products on joining.ProductID equals products.ProductID
select new RecentOrder(){
ID = orders.OrderID,
Placed = orders.OrderPlaced,
Total = orders.OrderTotal,
Name = products.ProductName,
Quantity = joining.Quantity
}
);

public static List<MostOrdered> MostOrdered = {
// The part I'm trying to figure out
};
}
public class OrderData
{
private static string format = "dd.MM.yyyy";
private static IsoDateTimeConverter converter = new IsoDateTimeConverter { DateTimeFormat = format };

private static string orderJson = File.ReadAllText("data/Orders.json");
private static string productJson = File.ReadAllText("data/Products.json");
private static string joiningJson = File.ReadAllText("data/OrderProducts.json");

private static List<Order> Orders = JsonConvert.DeserializeObject<List<Order>>(orderJson, converter);
private static List<Product> Products = JsonConvert.DeserializeObject<List<Product>>(productJson);
private static List<OrderProduct> Joining = JsonConvert.DeserializeObject<List<OrderProduct>>(joiningJson);

public static List<RecentOrder> RecentOrders = new List<RecentOrder> (from joining in Joining
join orders in Orders on joining.OrderID equals orders.OrderID
join products in Products on joining.ProductID equals products.ProductID
select new RecentOrder(){
ID = orders.OrderID,
Placed = orders.OrderPlaced,
Total = orders.OrderTotal,
Name = products.ProductName,
Quantity = joining.Quantity
}
);

public static List<MostOrdered> MostOrdered = {
// The part I'm trying to figure out
};
}
28 replies
CC#
Created by saki on 6/20/2023 in #help
❔ Sum quantity in a list by name value?
sure!
28 replies