using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using Common; public partial class Mobile_Customer : Page { public int CustomerId; public string UserId { get { return Page.User.Identity.IsAuthenticated ? Page.User.Identity.Name : string.Empty; } } protected void Page_Load(object sender, EventArgs e) { if (Page.RouteData.Values["id"] == null || !int.TryParse(Page.RouteData.Values["id"].ToString(), out CustomerId)) return; using (var db = new DataModel()) { var customer = db.Customers.FirstOrDefault(f => f.CustomerId == CustomerId); if (customer == null) { Response.Redirect("/Mobile/"); return; } Page.Title = customer.Name; ((Mobile_MobileMaster)Master).HeaderText = customer.Name; var openPickups = db.Workloads.Where(c => c.CustomerId == customer.CustomerId && c.WorkloadStatusId == 1).ToList(); if (openPickups.Count <= 0) return; var bags = db.CustomerWorkloadBags.Where(w => w.Workload.CustomerId == customer.CustomerId && w.Workload.WorkloadStatusId == 1).ToList(); if (bags.Count == 0) { BagsWaiting.Visible = false; BagsCollected.Visible = false; return; } var bagsWaiting = bags.Where(w => w.OperatorLoginId == 1).ToList(); if (bagsWaiting.Count == 0) BagsWaiting.Visible = false; else { BagsWaiting.DataSource = bagsWaiting; BagsWaiting.DataBind(); } var bagsCollected = bags.Where(w => w.OperatorLoginId != 1).ToList(); if (bagsCollected.Count == 0) BagsCollected.Visible = false; else { BagsCollected.DataSource = bagsCollected; BagsCollected.DataBind(); } } Trace.Warn("Customer", CustomerId.ToString()); } }