Exemple #1
0
        public StoreRecord CreateStore(int? teeyootUserId, string title, string description, string url, bool hideStore, bool crossSelling, IList<String> selectedCampaigns)
        {
            try
            {
                var store = new StoreRecord()
                {
                    Title = title,
                    Description = description,
                    CrossSelling = crossSelling,
                    HideStore = hideStore,
                    TeeyootUserId = teeyootUserId,
                    Url = url

                };
                
                _storeRepository.Create(store);
                List<LinkStoreCampaignRecord> campaigns = new List<LinkStoreCampaignRecord>();

                foreach (var campaignId in selectedCampaigns)
                {
                    var campaign = _campaignService.GetCampaignById(int.Parse(campaignId));
                    var storeCampaign = new LinkStoreCampaignRecord() { CampaignRecord = campaign, StoreRecord = store };
                    _linkStoreCampaignRepository.Create(storeCampaign);
                    campaigns.Add(storeCampaign);
                }

                store.Campaigns = campaigns;
                return store;
            }
            catch
            {
                throw;
            }         
        }
Exemple #2
0
        public void UpdateStore(int id, int? teeyootUserId, string title, string description, string url, bool hideStore, bool crossSelling, IList<String> selectedCampaigns)
        {             
            try
            {
                var store = GetStoreById(id);
                store.Title = title;
                store.Description = description;
                store.Url = url;
                store.HideStore = hideStore;
                store.CrossSelling = crossSelling;

                foreach (var link in store.Campaigns)
                {                  
                        _linkStoreCampaignRepository.Delete(link);                       
                }

                List<LinkStoreCampaignRecord> campaigns = new List<LinkStoreCampaignRecord>();

                foreach (var campaignId in selectedCampaigns)
                {
                    var campaign = _campaignService.GetCampaignById(int.Parse(campaignId));
                    var storeCampaign = new LinkStoreCampaignRecord() { CampaignRecord = campaign, StoreRecord = store };
                    _linkStoreCampaignRepository.Create(storeCampaign);
                    campaigns.Add(storeCampaign);
                }

                store.Campaigns = campaigns;

                _storeRepository.Update(store);
            }
            catch
            {
                throw;
            }      
        }