public void AddOrUpdateComboOfferRelation(SKUComboRelation offerRelation) { try { var allRelations = this.GetAllSKUComboOfferRelationData(); var existingRelation = allRelations .FirstOrDefault(a => a.SKUId == offerRelation.SKUId && a.ComboOfferId == offerRelation.ComboOfferId); if (existingRelation != null) { var index = allRelations.IndexOf(existingRelation); if (index > 0) { allRelations[index] = existingRelation; } else { throw new IndexOutOfRangeException("Invalid item: The SKU Offer relation is not found in the system"); } } else { allRelations.Add(offerRelation); } this._masterData.Relation.SKUComboOfferRelations = allRelations; string newJsonResult = JsonConvert.SerializeObject(this._masterData, Formatting.Indented); File.WriteAllText(this.jsonFilePath, newJsonResult); } catch (Exception ex) { throw new Exception(ex.Message); } }
public ActionResult ApplyComboOffer(SKUComboRelation offerRelation) { try { this._promotionDataService.ApplyComboOffer(offerRelation); return(Ok()); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public void ApplyComboOffer(SKUComboRelation comboRelation) { this._promotionRepo.AddOrUpdateComboOfferRelation(comboRelation); }