protected ExOzProductOption updateProductOption(ExOzProductOptionResponse item, ExOzProductOption exOzProductOption, long eventTicketDetailId, long sessionId, Guid ModifiedBy) { ExOzProductOption exOzProductOptionInserted = new ExOzProductOption(); if (exOzProductOption == null) { var newExOzProductOption = new ExOzProductOption { ProductOptionId = item.Id, Name = item.Name, Price = Convert.ToDecimal(item.Price), SessionId = sessionId, EventTicketDetailId = eventTicketDetailId, RetailPrice = Convert.ToDecimal(item.RetailPrice), MaxQty = item.MaxQty, MinQty = item.MinQty, DefaultQty = item.DefaultQty, Multiple = item.Multiple, Weight = item.Weight, IsFromPrice = item.IsFromPrice, ModifiedBy = ModifiedBy, IsEnabled = true, }; exOzProductOptionInserted = _exOzProductOptionRepository.Save(newExOzProductOption); } else { exOzProductOption.IsEnabled = true; exOzProductOption.ModifiedBy = ModifiedBy; exOzProductOptionInserted = _exOzProductOptionRepository.Save(exOzProductOption); } return(exOzProductOptionInserted); }
protected void UpdateAllOptions(SaveExOzProductOptionCommand command) { List <long> apiProductOptionIds = command.OptionList.Select(w => w.Id).ToList(); var exOzProductOptions = _exOzProductOptionRepository.GetByOptionIds(apiProductOptionIds); var eventTicketDetailIds = exOzProductOptions.Select(w => w.EventTicketDetailId).ToList(); var FilEventTicketDetails = _eventTicketDetailRepository.GetByIds(eventTicketDetailIds); var ticketCategoryIds = FilEventTicketDetails.Select(w => w.TicketCategoryId).ToList(); var FilTicketCategories = _ticketCategoryRepository.GetByTicketCategoryIds(ticketCategoryIds); foreach (var item in command.OptionList) { int optionCount = command.OptionList.Where(w => w.SessionId == item.SessionId).ToList().Count; try { string TicketCategoryName = GetTicketCategoryName(item, optionCount); ExOzProductOption exOzProductOption = exOzProductOptions.Where(w => w.ProductOptionId == item.Id).FirstOrDefault(); ExOzProductSession exOzProductSession = _exOzProductSessionRepository.GetBySessionId(item.SessionId); ExOzProduct exOzProduct = _exOzProductRepository.Get(exOzProductSession.ProductId); EventTicketDetail FilEventTicketDetail = FilEventTicketDetails.Where(w => w.Id == exOzProductOption.EventTicketDetailId).FirstOrDefault(); TicketCategory FilTicketCategory = FilTicketCategories.Where(w => w.Name == TicketCategoryName).FirstOrDefault(); TicketCategory retTicketCategory = UpdateTicketCategory(TicketCategoryName, FilTicketCategory, command.ModifiedBy); EventTicketDetail retEventTicketDetail = UpdateEventTicketDetail(FilEventTicketDetail, exOzProduct.EventDetailId, retTicketCategory.Id, command.ModifiedBy); EventTicketAttribute eventTicketAttribute = _eventTicketAttributeRepository.GetByEventTicketDetailId(retEventTicketDetail.Id); EventTicketAttribute FilTicketAttribute = UpdateEventTicketAttribute(item, eventTicketAttribute, retEventTicketDetail.Id, command.ModifiedBy); TicketFeeDetail ticketFeeDetail = _ticketFeeDetailRepository.GetByEventTicketAttributeId(FilTicketAttribute.EventTicketDetailId); TicketFeeDetail FilTicketFeedDetail = UpdateTicketFeeDetails(ticketFeeDetail, FilTicketAttribute.Id, command.ModifiedBy); ExOzProductOption retOption = updateProductOption(item, exOzProductOption, retEventTicketDetail.Id, exOzProductSession.Id, command.ModifiedBy); updatedOptions.OptionList.Add(retOption); } catch (Exception e) { throw; } } }