예제 #1
0
        public IHttpActionResult SendDynamicNotificationAnStoreEmail(webModel.SendDynamicNotificationRequest request)
        {
            var store = _storeService.GetById(request.StoreId);

            if (store == null)
            {
                throw new NullReferenceException(string.Format("no store with this id = {0}", request.StoreId));
            }

            if (string.IsNullOrEmpty(store.Email) && string.IsNullOrEmpty(store.AdminEmail))
            {
                throw new NullReferenceException(string.Format("set email or admin email for store with id = {0}", request.StoreId));
            }

            var notification = _notificationManager.GetNewNotification <StoreDynamicEmailNotification>(request.StoreId, "Store", request.Language);

            notification.Recipient = !string.IsNullOrEmpty(store.Email) ? store.Email : store.AdminEmail;
            notification.IsActive  = true;
            notification.FormType  = request.Type;
            notification.Fields    = request.Fields;

            _notificationManager.ScheduleSendNotification(notification);

            return(StatusCode(System.Net.HttpStatusCode.NoContent));
        }
예제 #2
0
        public IHttpActionResult SendDynamicNotificationAnStoreEmail(webModel.SendDynamicNotificationRequest request)
        {
            var store = _storeService.GetById(request.StoreId);

            if (store == null)
            {
                throw new InvalidOperationException(string.Concat("Store not found. StoreId: ", request.StoreId));
            }

            if (string.IsNullOrEmpty(store.Email) && string.IsNullOrEmpty(store.AdminEmail))
            {
                throw new InvalidOperationException(string.Concat("Both store email and admin email are empty. StoreId: ", request.StoreId));
            }

            var notification = _notificationManager.GetNewNotification <StoreDynamicEmailNotification>(request.StoreId, "Store", request.Language);

            notification.Recipient = !string.IsNullOrEmpty(store.Email) ? store.Email : store.AdminEmail;
            notification.Sender    = notification.Recipient;
            notification.IsActive  = true;
            notification.FormType  = request.Type;
            notification.Fields    = request.Fields;

            _notificationManager.ScheduleSendNotification(notification);

            return(StatusCode(HttpStatusCode.NoContent));
        }