protected void FillDataGrid() { var converter = new SpecEntityModelConverter(DataContext); var entities = (from n in DataContext.LP_Specs where n.DateDeleted == null orderby n.OrderIndex, n.DateCreated select n).ToList(); var models = entities.Select(n => converter.Convert(n)).ToList(); var specsModel = new SpecsModel { List = models }; specTreeControl.Model = specsModel; }
public ActionResult Specs(int id) { //Model that can hold base instance of a Person object to use for returning properties //Used because you can only return one thing, that this one thing can hold the many things we need to return SpecsModel specs = new SpecsModel(); //Assigning the found given id to the Person object specs.Person = db.People.Find(id); //Check if person is a Primary Contact Person if (specs.Person.Customers2.Count() <= 0) { //If false dont show anything else ViewBag.IsPrimary = false; } else { //If true then show the following info ViewBag.IsPrimary = true; //For Company Profile int customer_id = specs.Person.Customers2.FirstOrDefault().CustomerID; specs.Customer = db.Customers.Find(customer_id); //For Purchase History Summary //Sales ViewBag.Sales = specs.Customer.Orders.SelectMany(invoice => invoice.Invoices) .SelectMany(invoicelines => invoicelines.InvoiceLines) .Sum(sales => sales.ExtendedPrice); //Profit ViewBag.Profit = specs.Customer.Orders.SelectMany(invoice => invoice.Invoices) .SelectMany(invoicelines => invoicelines.InvoiceLines) .Sum(profit => profit.LineProfit); //For Items Purchased specs.InvoiceLine = specs.Customer.Orders.SelectMany(invoice => invoice.Invoices) .SelectMany(invoicelines => invoicelines.InvoiceLines) .OrderByDescending(profit => profit.LineProfit) .Take(10) .ToList(); } //return the specsmodel return(View(specs)); }
protected void Page_Load(object sender, EventArgs e) { var currentLanguage = LanguageUtil.GetLanguage(); var specID = DataConverter.ToNullableGuid(Request["ID"]); var spec = DataContext.LP_Specs.FirstOrDefault(n => n.ID == specID); if (spec == null) { var mainSpecs = (from n in DataContext.LP_Specs where n.DateDeleted == null && n.ParentID == null && (n.Language == currentLanguage || n.Language == null || n.Language == "") select n).ToList(); var converter = new SpecEntityModelConverter(DataContext); var models = (from n in mainSpecs let c = converter.Convert(n) select c).ToList(); var specsModel = new SpecsModel { List = models }; categoriesControl.Model = specsModel; pnlSpecData.Visible = false; pnlSpecCategories.Visible = true; } else if (spec.IsCategory.GetValueOrDefault()) { var mainSpecs = (from n in spec.Children where n.DateDeleted == null && (n.Language == currentLanguage || n.Language == null || n.Language == "") select n).ToList(); var converter = new SpecEntityModelConverter(DataContext); var models = (from n in mainSpecs let c = converter.Convert(n) select c).ToList(); var specsModel = new SpecsModel { List = models }; categoriesControl.Model = specsModel; pnlSpecData.Visible = false; pnlSpecCategories.Visible = true; } else { var converter = new SpecEntityModelConverter(DataContext); var model = converter.Convert(spec); specControl.Model = model; pnlSpecData.Visible = true; pnlSpecCategories.Visible = false; } }