public void AddOrUpdateInvidialOfferRelation(SKUIndividualOfferRelation offerRelation)
 {
     try
     {
         var allRelations     = this.GetAllIndividualSKUOfferRelationData();
         var existingRelation = allRelations
                                .FirstOrDefault(a => a.SKUId == offerRelation.SKUId && a.OfferId == offerRelation.OfferId);
         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.SKUIndividualOfferRelations = allRelations;
         string newJsonResult = JsonConvert.SerializeObject(this._masterData, Formatting.Indented);
         File.WriteAllText(this.jsonFilePath, newJsonResult);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
        public ActionResult ApplyIndividualOffer(SKUIndividualOfferRelation offerRelation)
        {
            try
            {
                this._promotionDataService.ApplyIndividualOffer(offerRelation);
                return(Ok());
            }

            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Esempio n. 3
0
 public void ApplyIndividualOffer(SKUIndividualOfferRelation offerRelation)
 {
     this._promotionRepo.AddOrUpdateInvidialOfferRelation(offerRelation);
 }