protected void UpdateProductImages(ExOzProductResponse product, long EventDetailId, long ProductId, Guid ModifiedBy) { List <ExOzProductImage> exOzProductImages = _exOzProductImageRepository.GetByProductId(product.Id).ToList(); foreach (var img in product.Images) { ExOzProductImage exOzProductImage = exOzProductImages.Where(w => w.ImageURL == img).FirstOrDefault(); if (exOzProductImage == null) { ExOzProductImage newImage = new ExOzProductImage() { ImageURL = img, ProductId = ProductId, EventDetailId = EventDetailId, IsEnabled = true, ModifiedBy = ModifiedBy, }; exOzProductImage = _exOzProductImageRepository.Save(newImage); } else { exOzProductImage.IsEnabled = true; exOzProductImage.ModifiedBy = ModifiedBy; exOzProductImage = _exOzProductImageRepository.Save(exOzProductImage); } } }
protected void UpdateProductHighlights(ExOzProductResponse product, long EventDetailId, long ProductId, Guid ModifiedBy) { List <ExOzProductHighlight> exOzProductHighlights = _exOzProductHighlightRepository.GetByProductId(product.Id).ToList(); foreach (var highlight in product.Highlights) { ExOzProductHighlight exOzProductHighlight = exOzProductHighlights.Where(w => w.Highlight == highlight).FirstOrDefault(); if (exOzProductHighlight == null) { ExOzProductHighlight newHighlight = new ExOzProductHighlight() { Highlight = highlight, ProductId = ProductId, EventDetailId = EventDetailId, IsEnabled = true, ModifiedBy = ModifiedBy, }; exOzProductHighlight = _exOzProductHighlightRepository.Save(newHighlight); } else { exOzProductHighlight.IsEnabled = true; exOzProductHighlight.ModifiedBy = ModifiedBy; exOzProductHighlight = _exOzProductHighlightRepository.Save(exOzProductHighlight); } } }
protected ExOzProduct UpdateProduct(ExOzProductResponse item, ExOzProduct exOzProduct, long FilEventDetailId, int FilVenueId, Guid ModifiedBy) { ExOzProduct exOzProductInserted = new ExOzProduct(); if (exOzProduct == null) { var newExOzProduct = new ExOzProduct { ProductId = item.Id, Name = item.Name, UrlSegment = item.UrlSegment, Summary = item.Summary, OperatorId = item.OperatorId, EventDetailId = FilEventDetailId, VenueId = FilVenueId, CanonicalRegionUrlSegment = item.CanonicalRegionUrlSegment, BookingRequired = item.BookingRequired, HandlerKey = item.HandlerKey, Title = item.Title, Timestamp = item.Timestamp, OperatorName = item.OperatorName, Description = item.Description, MoreInfo = item.MoreInfo, Tips = item.Tips, ModifiedBy = ModifiedBy, IsEnabled = true, HelpCode = item.HelpCode, Timezone = item.Timezone, }; exOzProductInserted = _exOzProductRepository.Save(newExOzProduct); } else { exOzProduct.IsEnabled = true; exOzProduct.ModifiedBy = ModifiedBy; exOzProductInserted = _exOzProductRepository.Save(exOzProduct); } return(exOzProductInserted); }
public async Task <SessionList> Synchronize(ProductList productList) { string line = ""; int i = 0; foreach (var prod in productList.Products) { ProductList productDetails = new ProductList() { Products = new List <ExOzProductResponse>() }; string input = prod.CanonicalRegionUrlSegment + "/" + prod.OperatorUrlSegment + "/" + prod.UrlSegment; ExOzProductResponse objProduct = new ExOzProductResponse(); string postResponse = HttpWebRequestHelper.ExOz_WebRequestGet(input); if (postResponse != "0") { objProduct = Mapper <ExOzProductResponse> .MapFromJson(postResponse); } objProduct.Name = CommonFunctions.replaceSingleQuotes(objProduct.Name); objProduct.Summary = CommonFunctions.replaceSingleQuotes(objProduct.Summary); objProduct.OperatorPublicName = CommonFunctions.replaceSingleQuotes(objProduct.OperatorPublicName); objProduct.Title = CommonFunctions.replaceSingleQuotes(objProduct.Title); objProduct.Description = CommonFunctions.replaceSingleQuotes(objProduct.Description); objProduct.MoreInfo = CommonFunctions.replaceSingleQuotes(objProduct.MoreInfo); objProduct.Tips = CommonFunctions.replaceSingleQuotes(objProduct.Tips); productDetails.Products.Add(objProduct); SaveExOzProductCommandResult retProducts = new SaveExOzProductCommandResult() { ProductList = new List <Contracts.DataModels.ExOzProduct>() }; retProducts = await _commandSender.Send <SaveExOzProductCommand, SaveExOzProductCommandResult>(new SaveExOzProductCommand { ProductList = productDetails.Products, ModifiedBy = new Guid("C043DDEE-D0B1-48D8-9C3F-309A77F44793") }); if (objProduct.ProductSessions != null) { SessionList sessionList = new SessionList() { ProductSessions = new List <ExOzSessionResponse>() }; foreach (var sess in objProduct.ProductSessions) { sess.ProductId = objProduct.Id; sessionList.ProductSessions.Add(sess); } _logger.StartMsg("Sessions"); ProductOptionList productOptionResponse = await _productSessionSynchronizer.Synchronize(sessionList); } i++; line = _logger.Update(i, productList.Products.Count, line); } //Insert Products Here //try //{ // _logger.FinishMsg(retProducts.ProductList.Count, "Products"); // return sessionList; //} //catch (Exception e) //{ // _logger.Log($"Exception: {e.Message}"); // throw; //} return(null); }