protected void UpdateAllProducts(SaveExOzProductCommand command) { int i = 0; List <string> apiProductNames = command.ProductList.Select(w => w.Name).Distinct().ToList(); var FilEventDetails = _eventDetailRepository.GetByNames(apiProductNames); var exOzProducts = _exOzProductRepository.GetByNames(apiProductNames); foreach (var item in command.ProductList) { i++; ExOzProduct exOzProduct = exOzProducts.Where(w => w.ProductId == item.Id).FirstOrDefault(); EventDetail FilEventDetail = FilEventDetails.Where(w => w.Name == item.Name).FirstOrDefault(); ExOzOperator exOzOperator = _exOzOperatorRepository.GetByUrlSegment(item.OperatorUrlSegment); Event FilEvent = _eventRepository.GetAllByName(exOzOperator.Name).FirstOrDefault(); //Venue FilVenue = _venueRepository.GetByName(item.Geolocations[0].Address); //if (FilVenue == null) //{ // ExOzRegion exOzRegion = _exOzRegionRepository.GetByUrlSegment(exOzOperator.CanonicalRegionUrlSegment); // City FilCity = _cityRepository.GetByName(exOzRegion.Name); // FilVenue = UpdateVenue(item.Geolocations[0], FilVenue, FilCity.Id, command.ModifiedBy); //} try { EventDetail retEventDetail = UpdateEventDetail(item.Name, FilEventDetail, FilEvent.Id, (int)exOzOperator.VenueId, command.ModifiedBy); ExOzProduct retProduct = UpdateProduct(item, exOzProduct, retEventDetail.Id, (int)exOzOperator.VenueId, command.ModifiedBy); updatedProducts.ProductList.Add(retProduct); UpdateProductImages(item, retEventDetail.Id, retProduct.Id, command.ModifiedBy); UpdateProductHighlights(item, retEventDetail.Id, retProduct.Id, command.ModifiedBy); } catch (Exception e) { throw; } } }