public List <CustomerForSelectionVwMdl> getCustomerList() { var result = new List <CustomerForSelectionVwMdl>(); if (!Initialized) { return(result); } var customers = new GETCore.Classes.CustomerManagement().getListOfActiveCustomersForLoggedInUser(userTableId); return(customers.Select(m => new CustomerForSelectionVwMdl { Id = longNullableToint(m.customerId), Title = m.customerName }).ToList()); }
public List <CustomerForSelectionVwMdl> getCustomerListForSelection(int PageNo, int PageSize) { PageNo = PageNo <= 1 ? 0 : PageNo - 1; var result = new List <CustomerForSelectionVwMdl>(); if (!Initialized) { return(result); } var customers = new GETCore.Classes.CustomerManagement().getListOfActiveCustomersForLoggedInUser(userTableId); return(customers.Select(m => new CustomerForSelectionVwMdl { Id = longNullableToint(m.customerId), Title = m.customerName }).GroupBy(m => m.Id).Select(m => m.First()).Skip(PageNo * PageSize).Take(PageSize).OrderBy(m => m.Title).ToList()); }
public List <ucDashbordViewModel> getEquipmentDetailsList(int PageNo, int PageSize, System.Security.Principal.IPrincipal User) { PageNo = PageNo <= 1 ? 0 : PageNo - 1; var result = new List <ucDashbordViewModel>(); if (!Initialized) { return(result); } var customerIds = new GETCore.Classes.CustomerManagement().getListOfActiveCustomersForLoggedInUser(userTableId).Select(m => m.customerId); var GETEquipments = new List <Core.Domain.IdAndDate>(); foreach (var id in customerIds) { GETEquipments.AddRange(new GETCore.Classes.GETEquipment().getEquipmentIdAndDateByCustomer(id, User)); } GETEquipments = GETEquipments.GroupBy(m => m).Select(m => m.First()).OrderByDescending(m => m.Id).OrderByDescending(m => m.Date).Skip(PageNo * PageSize).Take(PageSize).ToList(); foreach (var equipmentIdAndDate in GETEquipments) { var logicalEquipment = new Equipment(new DAL.UndercarriageContext(), longNullableToint(equipmentIdAndDate.Id)); var latestInspection = logicalEquipment.GetLatestInspection(DateTime.Now); //var systemDetails = logicalEquipment.getSystemDetailsList(DateTime.Now); try { var customer = logicalEquipment.getDALCustomer(); var Eqmake = logicalEquipment.GetEquipmentMake(); var jSite = logicalEquipment.getEquipmentJobSite(); string EqjobsiteName = jSite == null ? "-" : jSite.site_name; var componentsOverView = logicalEquipment.getEquipmentComponentsWorn(DateTime.Now); var k = new ucDashbordViewModel { Id = logicalEquipment.Id, customerId = customer == null ? 0 : customer.customer_auto.LongNullableToInt(), customerName = customer == null ? "-" : customer.cust_name, jobsiteId = logicalEquipment.DALEquipment.crsf_auto.LongNullableToInt(), jobsiteName = EqjobsiteName, family = logicalEquipment.GetFamilyName(logicalEquipment.GetEquipmentFamily()), familyId = (int)logicalEquipment.GetEquipmentFamily(), lastInspectionId = latestInspection == null ? 0 : latestInspection.inspection_auto, lastInspectionDate = latestInspection == null ? "Not inspected yet!" : latestInspection.inspection_date.ToString("dd MMM yyyy"), quoteId = latestInspection == null ? 0 : (latestInspection.quote_auto.HasValue ? (int)latestInspection.quote_auto : 0), ltd = logicalEquipment.GetEquipmentLife(DateTime.Now), make = Eqmake.Description, makeId = Eqmake.Id, model = logicalEquipment.DALEquipment.LU_MMTA.MODEL.modeldesc, modelId = logicalEquipment.DALEquipment.LU_MMTA.MODEL.model_auto, serial = logicalEquipment.DALEquipment.serialno, unit = logicalEquipment.DALEquipment.unitno, smu = logicalEquipment.GetSerialMeterUnit(DateTime.Now), EvalL = componentsOverView.Where(m => m.side == Side.Left).Select(m => m.Eval).Count() > 0 ? componentsOverView.Where(m => m.side == Side.Left).Select(m => m.Eval).Max() : "U", //logicalEquipment.toEvalChar(systemDetails.Where(m => m.Side == Side.Left).Count() > 0 ? systemDetails.Where(m => m.Side == Side.Left).Max(m => m.Eval) : EvalCode.U), EvalR = componentsOverView.Where(m => m.side == Side.Right).Select(m => m.Eval).Count() > 0 ? componentsOverView.Where(m => m.side == Side.Right).Select(m => m.Eval).Max() : "U", //logicalEquipment.toEvalChar(systemDetails.Where(m => m.Side == Side.Right).Count() > 0 ? systemDetails.Where(m => m.Side == Side.Right).Max(m => m.Eval) : EvalCode.U), overAllEvalNumber = componentsOverView.Select(m => m.wornPercentage).Count() > 0 ? componentsOverView.Select(m => m.wornPercentage).Max() : -1, }; result.Add(k); } catch (Exception ex) { string message = ex.Message; } } return(result); }