public ActionResult SaveChanges(EditCampaignViewModel editCampaign)
        {
            var campaign = _campaignService.GetCampaignById(editCampaign.Id);

            campaign.Title = editCampaign.Title;
            campaign.Description = editCampaign.Description;
            //campaign.Alias = editCampaign.Alias;
            campaign.BackSideByDefault = editCampaign.BackSideByDefault;

            var campaignTags = _linkCampaignAndCategoryRepository.Table
                .Where(t => t.CampaignRecord == campaign)
                .ToList();

            // Delete existing campaign tags
            foreach (var campaignTag in campaignTags)
            {
                _linkCampaignAndCategoryRepository.Delete(campaignTag);
            }

            // Create new campaign tags
            string[] tagsToSave = { };
            if (editCampaign.TagsToSave != null)
            {
                tagsToSave = editCampaign.TagsToSave.Split(',');
            }

            foreach (var tagToSave in tagsToSave)
            {
                var tag = _campaignCategoryRepository.Table
                    .FirstOrDefault(t => t.Name.ToLowerInvariant() == tagToSave.ToLowerInvariant());

                if (tag == null)
                {
                    tag = new CampaignCategoriesRecord
                    {
                        Name = tagToSave,
                        IsVisible = false,
                        CategoriesCulture = cultureUsed
                    };

                    _campaignCategoryRepository.Create(tag);
                }

                var campaignTag = new LinkCampaignAndCategoriesRecord
                {
                    CampaignRecord = campaign,
                    CampaignCategoriesPartRecord = tag
                };

                _linkCampaignAndCategoryRepository.Create(campaignTag);
            }

            _notifier.Information(T("Campaign was updated successfully"));
            return RedirectToAction("Campaigns");
        }
        public ActionResult EditCampaign(int id)
        {
            CampaignRecord camp = _campaignService.GetCampaignById(id);
            var user = Services.WorkContext.CurrentUser;
            if (camp.TeeyootUserId != user.Id)
            {
                return View("EditCampaign", new EditCampaignViewModel { IsError = true });
            }

            var allTags = _campaignService.GetAllCategories()
                .Select(t => new TagViewModel { name = t.Name })
                .ToList();

            var tags = _campaignCategoryService.GetCategoryByCampaignId(camp.Id)
                .Select(t => t.Name)
                .ToList();

            int product = _campaignService.GetProductsOfCampaign(id).Where(c => c.WhenDeleted == null).First().Id;

            string path = "/Media/campaigns/" + camp.Id.ToString() + "/" + product.ToString() + "/";
            string backIMG;
            string frontIMG;
            if (camp.BackSideByDefault)
            {
                backIMG = path + "normal/front.png";
                frontIMG = path + "normal/back.png";
            }
            else
            {
                backIMG = path + "normal/back.png";
                frontIMG = path + "normal/front.png";
            }

            var editCampaignViewModel = new EditCampaignViewModel
            {
                IsError = false,
                Id = camp.Id,
                Title = camp.Title,
                Description = camp.Description,
                AllTags = allTags,
                Tags = tags,
                Alias = camp.Alias,
                BackSideByDefault = camp.BackSideByDefault,
                FrontImagePath = frontIMG,
                BackImagePath = backIMG
            };

            return View("EditCampaign", editCampaignViewModel);
        }