public IActionResult OnGet(Guid orderDetailsId) { if (orderDetailsId == null || orderDetailsId.ToString() == "00000000-0000-0000-0000-000000000000") { return(Page()); } var quotationlocal = _context.Quotation .Include(q => q.OrderDetailsModel) .ThenInclude(q => q.Order) .Include(q => q.Tasks) .ThenInclude(t => t.ListMaterial) .FirstOrDefault(q => q.OrderDetailsModel.Id == orderDetailsId); var userOD = _context.OrderDetails .Include(od => od.Order) .Include(od => od.Service) .ThenInclude(s => s.ApplicationUser) .FirstOrDefault(od => od.Id == orderDetailsId); var orderDetailsServicesSameUser = _context.OrderDetails .Include(od => od.Order) .Include(od => od.Service) .ThenInclude(s => s.ApplicationUser) .Where(od => od.Service.ApplicationUser.Id == userOD.Service.ApplicationUser.Id && od.Order.Id == userOD.Order.Id).ToList(); if (quotationlocal == null) { _QuotationTaskMaterialVM = new QuotationTaskMaterialVM(orderDetailsId); _QuotationTaskMaterialVM.QuotationModel.OrderDetailsModel = _context.OrderDetails.Include(od => od.Order).FirstOrDefault(od => od.Id == orderDetailsId); } else { var listaTareaslocal = quotationlocal.Tasks; if (listaTareaslocal == null) { _QuotationTaskMaterialVM = new QuotationTaskMaterialVM(orderDetailsId, quotationlocal); } else { var listaMaterialesLocal = new List <Material>(); foreach (var item in listaTareaslocal) { var listaMaterialesDentroDelForEach = item.ListMaterial.ToList(); foreach (var objetoMaterial in listaMaterialesDentroDelForEach) { listaMaterialesLocal.Add(objetoMaterial); } } ; if (listaMaterialesLocal.Count() > 0) { _QuotationTaskMaterialVM = new QuotationTaskMaterialVM(orderDetailsId, quotationlocal, listaTareaslocal, listaMaterialesLocal); } else { _QuotationTaskMaterialVM = new QuotationTaskMaterialVM(orderDetailsId, quotationlocal, listaTareaslocal); } } foreach (var item in orderDetailsServicesSameUser) { _QuotationTaskMaterialVM.lstOrderDetailsSameUserServices.Add(item); } } return(Page()); }
private void LoadQuotation(Guid orderDetailsId) { _QuotationTaskMaterialVM = new QuotationTaskMaterialVM(); _QuotationTaskMaterialVM.orderDetailsId = orderDetailsId; _QuotationTaskMaterialVM.QuotationModel = _iqueries.GetQuotationIncludeOrderDetailsOrdersEmployeeTasksListMaterialPicturesFirstOrDefault(orderDetailsId); }