public void CopySocialMediaAccounts(int sourceEditionId, string languageCode, EditionTranslationEntity targetEditionTranslation)
        {
            var socialMedias = _editionTranslationSocialMediaServices.GetByEdition(sourceEditionId, languageCode);

            foreach (var sm in socialMedias)
            {
                var clonedEntity = (EditionTranslationSocialMediaEntity)sm.Clone();
                clonedEntity.EditionId            = targetEditionTranslation.EditionId;
                clonedEntity.EditionTranslationId = targetEditionTranslation.EditionTranslationId;
                _editionTranslationSocialMediaServices.Create(clonedEntity, Constants.AutoIntegrationUserId);
            }
        }
        public ActionResult _AddSocialMedia(int editionTranslationId, string socialMediaId, string accountName)
        {
            if (string.IsNullOrWhiteSpace(accountName))
            {
                return(Json(new { success = false, message = "Account name cannot be empty!" }, JsonRequestBehavior.AllowGet));
            }

            var editionTranslation = EditionTranslationServices.GetEditionTranslationById(editionTranslationId);

            if (editionTranslation == null)
            {
                return(Json(new { success = false, message = "Edition translation must be saved for this action." }, JsonRequestBehavior.AllowGet));
            }

            var edition = EditionServices.GetEditionById(editionTranslation.EditionId);

            if (edition == null)
            {
                return(Json(new { success = false, message = "Edition doesn't exist." }, JsonRequestBehavior.AllowGet));
            }

            var existingSocialMedia = SocialMediaServices.GetSocialMediaById(socialMediaId);

            if (existingSocialMedia == null)
            {
                socialMediaId = SocialMediaServices.CreateSocialMedia(socialMediaId);
            }

            if (!string.IsNullOrWhiteSpace(socialMediaId))
            {
                var existingEditionSocialMedia = EditionTranslationSocialMediaServices.Get(editionTranslationId, socialMediaId);

                if (existingEditionSocialMedia != null)
                {
                    return(Json(new { success = false, message = $"<i class='fa fa-{existingEditionSocialMedia.SocialMediaId}'></i> {existingEditionSocialMedia.SocialMediaId.ToEnumFromDescription<SocialMediaType>()} account already exists!" }, JsonRequestBehavior.AllowGet));
                }

                var editionSocialMedia = new EditionTranslationSocialMediaEntity
                {
                    EditionId            = editionTranslation.EditionId,
                    EditionTranslationId = editionTranslation.EditionTranslationId,
                    SocialMediaId        = socialMediaId,
                    AccountName          = accountName
                };
                EditionTranslationSocialMediaServices.Create(editionSocialMedia, CurrentCedUser.CurrentUser.UserId);


                var scopeName = "Social Media Account";

                // UPDATE EDITION
                UpdateEditionUpdateInfo(edition);

                // DIFF
                var diff = new List <Variance> {
                    new Variance {
                        Prop = scopeName, ValA = null, ValB = editionSocialMedia.SocialMediaId + "/" + editionSocialMedia.AccountName
                    }
                };

                OnEditionUpdated(edition, diff);

                // UPDATE LOG
                var updatedFields = NotificationControllerHelper.GetUpdatedFieldsAsJson(scopeName, new List <Variance> {
                    new Variance {
                        Prop = scopeName
                    }
                });
                UpdateLogInMemory(edition, updatedFields);

                return(Json(new { success = true, message = $"<i class='fa fa-{editionSocialMedia.SocialMediaId}'></i> {editionSocialMedia.SocialMediaId.ToEnumFromDescription<SocialMediaType>()} account has been added." }, JsonRequestBehavior.AllowGet));
            }

            return(Json(new { success = false, message = "<i class='fa fa-{editionSocialMedia.SocialMediaId}'></i> {editionSocialMedia.SocialMediaId.ToEnum<SocialMediaType>()} account could not be added!" }, JsonRequestBehavior.AllowGet));
        }