Esempio n. 1
0
        public virtual IActionResult Delete(int id)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageEmailAccounts))
            {
                return(AccessDeniedView());
            }

            //try to get an email account with the specified id
            var emailAccount = _emailAccountService.GetEmailAccountById(id);

            if (emailAccount == null)
            {
                return(RedirectToAction("List"));
            }

            try
            {
                _emailAccountService.DeleteEmailAccount(emailAccount);

                //activity log
                _customerActivityService.InsertActivity("DeleteEmailAccount",
                                                        string.Format(_localizationService.GetResource("ActivityLog.DeleteEmailAccount"), emailAccount.Id), emailAccount);

                _notificationService.SuccessNotification(_localizationService.GetResource("Admin.Configuration.EmailAccounts.Deleted"));

                return(RedirectToAction("List"));
            }
            catch (Exception exc)
            {
                _notificationService.ErrorNotification(exc);
                return(RedirectToAction("Edit", new { id = emailAccount.Id }));
            }
        }
        public ActionResult Delete(int id)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageEmailAccounts))
            {
                return(AccessDeniedView());
            }

            var emailAccount = _emailAccountService.GetEmailAccountById(id);

            if (emailAccount == null)
            {
                //No email account found with the specified id
                return(RedirectToAction("List"));
            }

            try
            {
                _emailAccountService.DeleteEmailAccount(emailAccount);

                SuccessNotification(_localizationService.GetResource("Admin.Configuration.EmailAccounts.Deleted"));

                return(RedirectToAction("List"));
            }
            catch (Exception exc)
            {
                ErrorNotification(exc);
                return(RedirectToAction("Edit", new { id = emailAccount.Id }));
            }
        }
Esempio n. 3
0
        public IActionResult Delete(string id)
        {
            var emailAccount = _emailAccountService.GetEmailAccountById(id);

            if (emailAccount == null)
            {
                //No email account found with the specified id
                return(RedirectToAction("List"));
            }
            try
            {
                if (ModelState.IsValid)
                {
                    _emailAccountService.DeleteEmailAccount(emailAccount);
                    SuccessNotification(_localizationService.GetResource("Admin.Configuration.EmailAccounts.Deleted"));
                }
                else
                {
                    ErrorNotification(ModelState);
                }

                return(RedirectToAction("List"));
            }
            catch (Exception exc)
            {
                ErrorNotification(exc);
                return(RedirectToAction("Edit", new { id = emailAccount.Id }));
            }
        }
Esempio n. 4
0
        public virtual IActionResult Delete(int id)
        {
            //try to get an email account with the specified id
            EmailAccount emailAccount = _emailAccountService.GetEmailAccountById(id);

            if (emailAccount == null)
            {
                return(RedirectToAction("List"));
            }

            try
            {
                _emailAccountService.DeleteEmailAccount(emailAccount);

                //activity log
                _customerActivityService.InsertActivity("DeleteEmailAccount",
                                                        string.Format("DeleteEmailAccount{0}", emailAccount.Id), emailAccount);

                SuccessNotification("Deleted");

                return(RedirectToAction("List"));
            }
            catch (Exception exc)
            {
                ErrorNotification(exc);
                return(RedirectToAction("Edit", new { id = emailAccount.Id }));
            }
        }
        public ActionResult DeleteConfirmed(int id)
        {
            var emailAccount = _emailAccountService.GetEmailAccountById(id);

            if (emailAccount == null)
            {
                //No email account found with the specified id
                return(RedirectToAction("List"));
            }

            NotifySuccess(_localizationService.GetResource("Admin.Configuration.EmailAccounts.Deleted"));
            _emailAccountService.DeleteEmailAccount(emailAccount);
            return(RedirectToAction("List"));
        }
Esempio n. 6
0
        public HttpResponseMessage DeleteEmailAccount(HttpRequestMessage request, int id)
        {
            return(CreateHttpResponse(request, () =>
            {
                HttpResponseMessage response = request.CreateErrorResponse(HttpStatusCode.NotFound, "No items found");
                if (true)
                {
                    var emailAccount = _emailAccountService.GetEmailAccountById(id);
                    if (emailAccount == null)
                    {
                        //No email account found with the specified id
                        Url.Route("EmailList", null);
                        string uri = Url.Link("EmailList", null);
                        response.Headers.Location = new Uri(uri);
                        return response;
                    }

                    try
                    {
                        _emailAccountService.DeleteEmailAccount(emailAccount);

                        //activity log
                        _customerActivityService.InsertActivity("DeleteEmailAccount", _localizationService.GetResource("ActivityLog.DeleteEmailAccount"), emailAccount.Id);

                        _baseService.Commit();

                        //SuccessNotification(_localizationService.GetResource("Admin.Configuration.EmailAccounts.Deleted"));

                        Url.Route("EmailList", null);
                        string nUri = Url.Link("EmailList", null);
                        response.Headers.Location = new Uri(nUri);
                    }
                    catch (Exception exc)
                    {
                        LogError(exc);
                        Url.Route("GetEmailById", new { id = emailAccount.Id });
                        string nUri = Url.Link("GetEmailById", new { id = emailAccount.Id });
                        response.Headers.Location = new Uri(nUri);
                    }
                }
                else
                {
                    response = AccessDeniedView(request);
                    // response = request.CreateResponse(HttpStatusCode.Unauthorized, "Unauthorized user");
                }
                return response;
            }));
        }
        /// <summary>
        /// Uninstall the plugin
        /// </summary>
        public override void Uninstall()
        {
            //smtp accounts
            foreach (var store in _storeService.GetAllStores())
            {
                var key            = $"{nameof(SendinBlueSettings)}.{nameof(SendinBlueSettings.EmailAccountId)}";
                var emailAccountId = _settingService.GetSettingByKey <int>(key, storeId: store.Id, loadSharedValueIfNotFound: true);
                var emailAccount   = _emailAccountService.GetEmailAccountById(emailAccountId);
                if (emailAccount != null)
                {
                    _emailAccountService.DeleteEmailAccount(emailAccount);
                }
            }

            //settings
            if (_widgetSettings.ActiveWidgetSystemNames.Contains(SendinBlueDefaults.SystemName))
            {
                _widgetSettings.ActiveWidgetSystemNames.Remove(SendinBlueDefaults.SystemName);
                _settingService.SaveSetting(_widgetSettings);
            }
            _settingService.DeleteSetting <SendinBlueSettings>();

            //generic attributes
            foreach (var store in _storeService.GetAllStores())
            {
                var messageTemplates = _messageTemplateService.GetAllMessageTemplates(store.Id);
                foreach (var messageTemplate in messageTemplates)
                {
                    _genericAttributeService.SaveAttribute <int?>(messageTemplate, SendinBlueDefaults.TemplateIdAttribute, null);
                }
            }

            //schedule task
            var task = _scheduleTaskService.GetTaskByType(SendinBlueDefaults.SynchronizationTask);

            if (task != null)
            {
                _scheduleTaskService.DeleteTask(task);
            }

            //locales
            _localizationService.DeleteLocaleResources("Plugins.Misc.SendinBlue");

            base.Uninstall();
        }
        public ActionResult DeleteConfirmed(int id)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageEmailAccounts))
            {
                return(AccessDeniedView());
            }

            var emailAccount = _emailAccountService.GetEmailAccountById(id);

            if (emailAccount == null)
            {
                throw new ArgumentException("No email account found with the specified id", "id");
            }

            SuccessNotification(_localizationService.GetResource("Admin.Configuration.EmailAccounts.Deleted"));
            _emailAccountService.DeleteEmailAccount(emailAccount);
            return(RedirectToAction("List"));
        }
        public virtual ActionResult Delete(int id)
        {
            var emailAccount = _emailAccountService.GetEmailAccountById(id);

            if (emailAccount == null)
            {
                return(Json(false));
            }

            try
            {
                _emailAccountService.DeleteEmailAccount(emailAccount);
                return(Json(true));
            }
            catch (Exception exc)
            {
                return(Json(false));
            }
        }
Esempio n. 10
0
        /// <summary>
        /// Uninstall the plugin
        /// </summary>
        public override void Uninstall()
        {
            //smtp accounts
            foreach (var store in _storeService.GetAllStores())
            {
                var key            = $"{nameof(SendinBlueSettings)}.{nameof(SendinBlueSettings.EmailAccountId)}";
                var emailAccountId = _settingService.GetSettingByKey <int>(key, storeId: store.Id, loadSharedValueIfNotFound: true);
                var emailAccount   = _emailAccountService.GetEmailAccountById(emailAccountId);
                if (emailAccount != null)
                {
                    _emailAccountService.DeleteEmailAccount(emailAccount);
                }
            }

            //settings
            if (_widgetSettings.ActiveWidgetSystemNames.Contains(SendinBlueDefaults.SystemName))
            {
                _widgetSettings.ActiveWidgetSystemNames.Remove(SendinBlueDefaults.SystemName);
                _settingService.SaveSetting(_widgetSettings);
            }
            _settingService.DeleteSetting <SendinBlueSettings>();

            //generic attributes
            foreach (var store in _storeService.GetAllStores())
            {
                var messageTemplates = _messageTemplateService.GetAllMessageTemplates(store.Id);
                foreach (var messageTemplate in messageTemplates)
                {
                    _genericAttributeService.SaveAttribute <int?>(messageTemplate, SendinBlueDefaults.TemplateIdAttribute, null);
                }
            }

            //schedule task
            var task = _scheduleTaskService.GetTaskByType(SendinBlueDefaults.SynchronizationTask);

            if (task != null)
            {
                _scheduleTaskService.DeleteTask(task);
            }

            //locales
            _localizationService.DeletePluginLocaleResource("Plugins.Misc.SendinBlue.AccountInfo");
            _localizationService.DeletePluginLocaleResource("Plugins.Misc.SendinBlue.AccountInfo.Hint");
            _localizationService.DeletePluginLocaleResource("Plugins.Misc.SendinBlue.ActivateSMTP");
            _localizationService.DeletePluginLocaleResource("Plugins.Misc.SendinBlue.AddNewSMSNotification");
            _localizationService.DeletePluginLocaleResource("Plugins.Misc.SendinBlue.BillingAddressPhone");
            _localizationService.DeletePluginLocaleResource("Plugins.Misc.SendinBlue.BillingAddressPhone");
            _localizationService.DeletePluginLocaleResource("Plugins.Misc.SendinBlue.CustomerPhone");
            _localizationService.DeletePluginLocaleResource("Plugins.Misc.SendinBlue.CustomerPhone");
            _localizationService.DeletePluginLocaleResource("Plugins.Misc.SendinBlue.EditTemplate");
            _localizationService.DeletePluginLocaleResource("Plugins.Misc.SendinBlue.EditTemplate");
            _localizationService.DeletePluginLocaleResource("Plugins.Misc.SendinBlue.Fields.AllowedTokens");
            _localizationService.DeletePluginLocaleResource("Plugins.Misc.SendinBlue.Fields.AllowedTokens.Hint");
            _localizationService.DeletePluginLocaleResource("Plugins.Misc.SendinBlue.Fields.ApiKey");
            _localizationService.DeletePluginLocaleResource("Plugins.Misc.SendinBlue.Fields.ApiKey.Hint");
            _localizationService.DeletePluginLocaleResource("Plugins.Misc.SendinBlue.Fields.CampaignList");
            _localizationService.DeletePluginLocaleResource("Plugins.Misc.SendinBlue.Fields.CampaignList.Hint");
            _localizationService.DeletePluginLocaleResource("Plugins.Misc.SendinBlue.Fields.CampaignSenderName");
            _localizationService.DeletePluginLocaleResource("Plugins.Misc.SendinBlue.Fields.CampaignSenderName.Hint");
            _localizationService.DeletePluginLocaleResource("Plugins.Misc.SendinBlue.Fields.CampaignText");
            _localizationService.DeletePluginLocaleResource("Plugins.Misc.SendinBlue.Fields.CampaignText.Hint");
            _localizationService.DeletePluginLocaleResource("Plugins.Misc.SendinBlue.Fields.List");
            _localizationService.DeletePluginLocaleResource("Plugins.Misc.SendinBlue.Fields.List.Hint");
            _localizationService.DeletePluginLocaleResource("Plugins.Misc.SendinBlue.Fields.MaKey");
            _localizationService.DeletePluginLocaleResource("Plugins.Misc.SendinBlue.Fields.MaKey.Hint");
            _localizationService.DeletePluginLocaleResource("Plugins.Misc.SendinBlue.Fields.Sender");
            _localizationService.DeletePluginLocaleResource("Plugins.Misc.SendinBlue.Fields.Sender.Hint");
            _localizationService.DeletePluginLocaleResource("Plugins.Misc.SendinBlue.Fields.SmsSenderName");
            _localizationService.DeletePluginLocaleResource("Plugins.Misc.SendinBlue.Fields.SmsSenderName.Hint");
            _localizationService.DeletePluginLocaleResource("Plugins.Misc.SendinBlue.Fields.SmtpKey");
            _localizationService.DeletePluginLocaleResource("Plugins.Misc.SendinBlue.Fields.SmtpKey.Hint");
            _localizationService.DeletePluginLocaleResource("Plugins.Misc.SendinBlue.Fields.StoreOwnerPhoneNumber");
            _localizationService.DeletePluginLocaleResource("Plugins.Misc.SendinBlue.Fields.StoreOwnerPhoneNumber.Hint");
            _localizationService.DeletePluginLocaleResource("Plugins.Misc.SendinBlue.Fields.TrackingScript");
            _localizationService.DeletePluginLocaleResource("Plugins.Misc.SendinBlue.Fields.TrackingScript.Hint");
            _localizationService.DeletePluginLocaleResource("Plugins.Misc.SendinBlue.Fields.UseMarketingAutomation");
            _localizationService.DeletePluginLocaleResource("Plugins.Misc.SendinBlue.Fields.UseMarketingAutomation.Hint");
            _localizationService.DeletePluginLocaleResource("Plugins.Misc.SendinBlue.Fields.UseSmsNotifications");
            _localizationService.DeletePluginLocaleResource("Plugins.Misc.SendinBlue.Fields.UseSmsNotifications.Hint");
            _localizationService.DeletePluginLocaleResource("Plugins.Misc.SendinBlue.Fields.UseSmtp");
            _localizationService.DeletePluginLocaleResource("Plugins.Misc.SendinBlue.Fields.UseSmtp.Hint");
            _localizationService.DeletePluginLocaleResource("Plugins.Misc.SendinBlue.General");
            _localizationService.DeletePluginLocaleResource("Plugins.Misc.SendinBlue.ImportProcess");
            _localizationService.DeletePluginLocaleResource("Plugins.Misc.SendinBlue.ManualSync");
            _localizationService.DeletePluginLocaleResource("Plugins.Misc.SendinBlue.SyncNow");
            _localizationService.DeletePluginLocaleResource("Plugins.Misc.SendinBlue.MarketingAutomation");
            _localizationService.DeletePluginLocaleResource("Plugins.Misc.SendinBlue.MyPhone");
            _localizationService.DeletePluginLocaleResource("Plugins.Misc.SendinBlue.MyPhone");
            _localizationService.DeletePluginLocaleResource("Plugins.Misc.SendinBlue.PhoneType");
            _localizationService.DeletePluginLocaleResource("Plugins.Misc.SendinBlue.PhoneType.Hint");
            _localizationService.DeletePluginLocaleResource("Plugins.Misc.SendinBlue.SendinBlueTemplate");
            _localizationService.DeletePluginLocaleResource("Plugins.Misc.SendinBlue.SendinBlueTemplate");
            _localizationService.DeletePluginLocaleResource("Plugins.Misc.SendinBlue.SendinBlueTemplate");
            _localizationService.DeletePluginLocaleResource("Plugins.Misc.SendinBlue.SMS");
            _localizationService.DeletePluginLocaleResource("Plugins.Misc.SendinBlue.SMS.Campaigns");
            _localizationService.DeletePluginLocaleResource("Plugins.Misc.SendinBlue.SMS.Campaigns.Sent");
            _localizationService.DeletePluginLocaleResource("Plugins.Misc.SendinBlue.SMS.Campaigns.Submit");
            _localizationService.DeletePluginLocaleResource("Plugins.Misc.SendinBlue.SMSText");
            _localizationService.DeletePluginLocaleResource("Plugins.Misc.SendinBlue.SMSText.Hint");
            _localizationService.DeletePluginLocaleResource("Plugins.Misc.SendinBlue.StandardTemplate");
            _localizationService.DeletePluginLocaleResource("Plugins.Misc.SendinBlue.Synchronization");
            _localizationService.DeletePluginLocaleResource("Plugins.Misc.SendinBlue.Transactional");
            _localizationService.DeletePluginLocaleResource("Plugins.Misc.SendinBlue.UseSendinBlueTemplate");

            base.Uninstall();
        }
Esempio n. 11
0
 /// <summary>
 /// Deletes an email account
 /// </summary>
 /// <param name="emailAccount">Email account</param>
 public void DeleteEmailAccount(EmailAccount emailAccount)
 {
     _emailAccountService.DeleteEmailAccount(emailAccount);
 }
 public JsonResult DeleteEmailAccount(int id)
 {
     return(Json(_emailAccountService.DeleteEmailAccount(id)));
 }
Esempio n. 13
0
        /// <summary>
        /// Uninstall the plugin
        /// </summary>
        public override void Uninstall()
        {
            //smtp accounts
            foreach (var store in _storeService.GetAllStores())
            {
                var emailAccountId = _settingService.GetSettingByKey <int>("SendInBlueSettings.SendInBlueEmailAccountId",
                                                                           storeId: store.Id, loadSharedValueIfNotFound: true);
                var emailAccount = _emailAccountService.GetEmailAccountById(emailAccountId);
                if (emailAccount != null)
                {
                    _emailAccountService.DeleteEmailAccount(emailAccount);
                }
            }

            //settings
            _settingService.DeleteSetting <SendInBlueSettings>();

            //remove scheduled task
            var task = _scheduleTaskService.GetTaskByType("Nop.Plugin.Misc.SendInBlue.Services.SendInBlueSynchronizationTask, Nop.Plugin.Misc.SendInBlue");

            if (task != null)
            {
                _scheduleTaskService.DeleteTask(task);
            }

            //locales
            this.DeletePluginLocaleResource("Plugins.Misc.SendInBlue.AccountInfo");
            this.DeletePluginLocaleResource("Plugins.Misc.SendInBlue.ActivateSMTP");
            this.DeletePluginLocaleResource("Plugins.Misc.SendInBlue.AddNewSMSNotification");
            this.DeletePluginLocaleResource("Plugins.Misc.SendInBlue.AutoSyncRestart");
            this.DeletePluginLocaleResource("Plugins.Misc.SendInBlue.BillingAddressPhone");
            this.DeletePluginLocaleResource("Plugins.Misc.SendInBlue.CustomerPhone");
            this.DeletePluginLocaleResource("Plugins.Misc.SendInBlue.EditTemplate");
            this.DeletePluginLocaleResource("Plugins.Misc.SendInBlue.General");
            this.DeletePluginLocaleResource("Plugins.Misc.SendInBlue.ImportProcess");
            this.DeletePluginLocaleResource("Plugins.Misc.SendInBlue.ManualSync");
            this.DeletePluginLocaleResource("Plugins.Misc.SendInBlue.MyPhone");
            this.DeletePluginLocaleResource("Plugins.Misc.SendInBlue.PhoneType");
            this.DeletePluginLocaleResource("Plugins.Misc.SendInBlue.SendInBlueTemplate");
            this.DeletePluginLocaleResource("Plugins.Misc.SendInBlue.SMS");
            this.DeletePluginLocaleResource("Plugins.Misc.SendInBlue.SMSActive");
            this.DeletePluginLocaleResource("Plugins.Misc.SendInBlue.SMSText");
            this.DeletePluginLocaleResource("Plugins.Misc.SendInBlue.StandardTemplate");
            this.DeletePluginLocaleResource("Plugins.Misc.SendInBlue.Synchronization");
            this.DeletePluginLocaleResource("Plugins.Misc.SendInBlue.TemplateType");
            this.DeletePluginLocaleResource("Plugins.Misc.SendInBlue.Transactional");
            this.DeletePluginLocaleResource("Plugins.Misc.SendInBlue.Fields.ApiKey");
            this.DeletePluginLocaleResource("Plugins.Misc.SendInBlue.Fields.ApiKey.Hint");
            this.DeletePluginLocaleResource("Plugins.Misc.SendInBlue.Fields.AutoSync");
            this.DeletePluginLocaleResource("Plugins.Misc.SendInBlue.Fields.AutoSync.Hint");
            this.DeletePluginLocaleResource("Plugins.Misc.SendInBlue.Fields.AutoSyncEachMinutes");
            this.DeletePluginLocaleResource("Plugins.Misc.SendInBlue.Fields.AutoSyncEachMinutes.Hint");
            this.DeletePluginLocaleResource("Plugins.Misc.SendInBlue.Fields.List");
            this.DeletePluginLocaleResource("Plugins.Misc.SendInBlue.Fields.List.Hint");
            this.DeletePluginLocaleResource("Plugins.Misc.SendInBlue.Fields.MyPhoneNumber");
            this.DeletePluginLocaleResource("Plugins.Misc.SendInBlue.Fields.MyPhoneNumber.Hint");
            this.DeletePluginLocaleResource("Plugins.Misc.SendInBlue.Fields.NewListName");
            this.DeletePluginLocaleResource("Plugins.Misc.SendInBlue.Fields.NewListName.Hint");
            this.DeletePluginLocaleResource("Plugins.Misc.SendInBlue.Fields.SMSFrom");
            this.DeletePluginLocaleResource("Plugins.Misc.SendInBlue.Fields.SMSFrom.Hint");
            this.DeletePluginLocaleResource("Plugins.Misc.SendInBlue.Fields.SMTPSender");
            this.DeletePluginLocaleResource("Plugins.Misc.SendInBlue.Fields.SMTPSender.Hint");
            this.DeletePluginLocaleResource("Plugins.Misc.SendInBlue.Fields.UseSendInBlueSMTP");
            this.DeletePluginLocaleResource("Plugins.Misc.SendInBlue.Fields.UseSendInBlueSMTP.Hint");
            this.DeletePluginLocaleResource("Plugins.Misc.SendInBlue.Fields.UseSMS");
            this.DeletePluginLocaleResource("Plugins.Misc.SendInBlue.Fields.UseSMS.Hint");

            base.Uninstall();
        }