Example #1
0
 public QRCodeController(string backEndType)
 {
     _backEndtype = backEndType;
     _dataWriter = new DataWriter(_backEndtype);
     _connectionController = new ConnectionController(_backEndtype);
     _responseController = new ResponseController(_connectionController.ConnectionString);
 }
        public IAsyncResult BeginCatalogBrochurePromote(string environment , PromoteRequest request, AsyncCallback callback, object state)
        {
            if (environment  == "catalogAdminProduction")
            {
                var t = Task<TransactionResponse>.Factory.StartNew(r => new TransactionResponse
                    {
                        EntityType = typeof (CatalogBrochure).ToString(),
                        Message = "Not Supported!",
                        ResponseCode = 500
                    }, state);

                return t.ContinueWith(r => callback(t));
            }

            var connectionController = new ConnectionController(environment );
            var controller = new ResponseController(connectionController.ConnectionString);

            var sproc = new CatalogPromoteStoredProcedure();
            sproc.SprocParameters["@CatalogId"] = request.CatalogId;
            sproc.SprocParameters["@User"] = request.UserName;

            var task = Task<TransactionResponse>.Factory.StartNew(r =>
                controller.ExecuteEntityTransaction<CatalogPromoteStoredProcedure, CatalogBrochure>(sproc), state);

            return task.ContinueWith(r => callback(task));
        }
        public IAsyncResult BeginCreateCatalogBrochure(string environment , CatalogBrochureRequest request, AsyncCallback callback, object state)
        {
            var connectionController = new ConnectionController(environment );
            var controller = new ResponseController(connectionController.ConnectionString);

            var sproc = new CatalogBrochureCreateStoredProcedure();
            sproc.SprocParameters["@Catalog"] = string.IsNullOrEmpty(request.Catalog) ? null : request.Catalog;
            sproc.SprocParameters["@SKU"] = string.IsNullOrEmpty(request.SKU) ? null :request.SKU;
            sproc.SprocParameters["@DefaultImageName"] = string.IsNullOrEmpty(request.DefaultImageName) ? null : request.DefaultImageName;
            sproc.SprocParameters["@DefaultLogoName"] = string.IsNullOrEmpty(request.DefaultLogoName) ? null : request.DefaultLogoName;
            sproc.SprocParameters["@Classification"] = request.Classification.HasValue ? request.Classification : null;
            sproc.SprocParameters["@DivisionCode"] = request.DivisionCode.HasValue ? request.DivisionCode : null;
            sproc.SprocParameters["@Active"] = request.Active.HasValue ? request.Active : null;
            sproc.SprocParameters["@Available"] = request.Available.HasValue ? request.Available : null;
            sproc.SprocParameters["@ShortName"] = string.IsNullOrEmpty(request.ShortName) ? null : request.ShortName;
            sproc.SprocParameters["@Price"] = request.Price.HasValue ? request.Price : null;
            sproc.SprocParameters["@Weight"] = request.Weight.HasValue ? request.Weight : null;
            sproc.SprocParameters["@CatalogYear"] = string.IsNullOrEmpty(request.CatalogYear) ? null : request.CatalogYear;
            sproc.SprocParameters["@Version"] = string.IsNullOrEmpty(request.Version) ? null : request.Version;
            sproc.SprocParameters["@ActiveDate"] = string.IsNullOrEmpty(request.ActiveDate) ? null : request.ActiveDate;
            sproc.SprocParameters["@MinFileSize"] = request.MinFileSize.HasValue ? request.MinFileSize : null;
            sproc.SprocParameters["@DeactiveDate"] = string.IsNullOrEmpty(request.DeactivationDate) ? null : request.DeactivationDate;
            sproc.SprocParameters["@PageCount"] = string.IsNullOrEmpty(request.PageCount) ? null : request.PageCount;
            sproc.SprocParameters["@Notes"] = string.IsNullOrEmpty(request.Notes) ? null : request.Notes;
            sproc.SprocParameters["@IsNew"] = request.IsNew == true ? 1 : 0;
            sproc.SprocParameters["@InitialPrintQty"] = request.InitialPrintQty.HasValue ? request.InitialPrintQty : null;
            sproc.SprocParameters["@Qty1"] = request.PrintQty1.HasValue ? request.PrintQty1 : null;
            sproc.SprocParameters["@Qty2"] = request.PrintQty2.HasValue ? request.PrintQty2 : null;
            sproc.SprocParameters["@IsElectricVehicle"] = request.IsElectricVehicle.HasValue ? request.IsElectricVehicle : null;
            sproc.SprocParameters["@LaunchNotes"] = string.IsNullOrEmpty(request.LaunchNotes) ? null : request.LaunchNotes;
            sproc.SprocParameters["@ShowInSchedule"] = request.ShowInSchedule.HasValue ? request.ShowInSchedule : null;
            sproc.SprocParameters["@QrCodeName"] = string.IsNullOrEmpty(request.QRCodeName) ? null : request.QRCodeName;
            sproc.SprocParameters["@User"] = request.UserName;
            sproc.SprocParameters["@CampaignId"] = request.CampaignId.HasValue ? request.CampaignId : null;

            var task = Task<CreateResponse>.Factory.StartNew(r =>
                controller.CreateEntity<CatalogBrochureCreateStoredProcedure, CatalogBrochure>(sproc), state);

            return task.ContinueWith(r => callback(task));
        }
        public IAsyncResult BeginUpdateCatalogBrochureImage(string environment , string sku, CatalogBrochureImageRequest request, AsyncCallback callback, object state)
        {
            var connectionController = new ConnectionController(environment );
            var controller = new ResponseController(connectionController.ConnectionString);

            var sproc = new CatalogUpdateImageStoredProcedure();
            sproc.SprocParameters["@SKU"] = sku;
            sproc.SprocParameters["@Image"] = Convert.FromBase64String(request.CatalogImage);
            sproc.SprocParameters["@CatalogImageName"] = request.CatalogImageName;
            sproc.SprocParameters["@User"] = request.UserName;

            var task = Task<TransactionResponse>.Factory.StartNew(r =>
                controller.ExecuteEntityTransaction<CatalogUpdateImageStoredProcedure, CatalogBrochure>(sproc), state);

            return task.ContinueWith(r => callback(task));
        }
        public IAsyncResult BeginSyncXmpie(string environment , string catalogId, CatalogXmpieSyncRequest request,
                                           AsyncCallback callback, object state)
        {
            var connectionController = new ConnectionController(environment );
            var controller = new ResponseController(connectionController.ConnectionString);

            var sproc = new XmpieSyncStoredProcedure();
            sproc.SprocParameters["@CampaignId"] = request.CampaignId;
            sproc.SprocParameters["@CatalogId"] = Convert.ToInt32(catalogId);
            sproc.SprocParameters["@DocumentId"] = request.DocumentId;
            sproc.SprocParameters["@DocumentName"] = request.DocumentName;
            sproc.SprocParameters["@PlanId"] = request.PlanId;
            sproc.SprocParameters["@PlanName"] = request.PlanName;
            sproc.SprocParameters["@VipDocId"] = request.VipDocId.HasValue ? request.VipDocId : null;
            sproc.SprocParameters["@User"] = request.UserName;

            var task = Task<TransactionResponse>.Factory.StartNew(r =>
                controller.ExecuteEntityTransaction<XmpieSyncStoredProcedure, CatalogBrochure>(sproc), state);

            return task.ContinueWith(r => callback(task));
        }
        public IAsyncResult BeginGetGenericQRCode(string environment , string sku, AsyncCallback callback, object state)
        {
            var connectionController = new ConnectionController(environment );
            var controller = new ResponseController(connectionController.ConnectionString);

            var sproc = new DealerQRCodeSelectGenericStoredProcedure();
            sproc.SprocParameters["@SKU"] = sku;

            var task = Task<Base64StringResponse>.Factory.StartNew(r => controller.ExecuteEntityByteArray<DealerQRCodeSelectGenericStoredProcedure>(sproc), state);

            return task.ContinueWith(r => callback(task));
        }
        public IAsyncResult BeginGetDivisionCodes(string environment , AsyncCallback callback, object state)
        {
            var connectionController = new ConnectionController(environment );
            var controller = new ResponseController(connectionController.ConnectionString);

            var sproc = new DivisionCodeSelectStoredProcedure();

            var task = Task<EntitySetResponse<DivisionCode>>.Factory.StartNew(r => controller.ExecuteEntitySet<DivisionCodeSelectStoredProcedure, DivisionCode>(sproc), state);

            return task.ContinueWith(r => callback(task));
        }
        public IAsyncResult BeginGetCatalogBrochures(string environment , string catalogYear, string catalogId, AsyncCallback callback, object state)
        {
            var connectionController = new ConnectionController(environment );
            var controller = new ResponseController(connectionController.ConnectionString);

            var sproc = new CatalogBrochureSelectStoredProcedure();
            sproc.SprocParameters["@Year"] = string.IsNullOrEmpty(catalogYear) ? null : catalogYear;
            sproc.SprocParameters["@CatalogId"] = string.IsNullOrEmpty(catalogId) ? (object)null : Convert.ToInt32(catalogId);

            var task = Task<EntitySetResponse<CatalogBrochure>>.Factory.StartNew(r => controller.ExecuteEntitySet<CatalogBrochureSelectStoredProcedure, CatalogBrochure>(sproc), state);

            return task.ContinueWith(r => callback(task));
        }
        public IAsyncResult BeginDeleteQRCode(string environment , string sku, AsyncCallback callback, object state)
        {
            var connectionController = new ConnectionController(environment );
            var controller = new ResponseController(connectionController.ConnectionString);

            var sproc = new DealerQRCodeDeleteStoredProcedure();
            sproc.SprocParameters["@Sku"] = sku;

            var task = Task<TransactionResponse>.Factory.StartNew(res =>
                controller.ExecuteEntityTransaction<DealerQRCodeDeleteStoredProcedure, DealerQRCode>(sproc), state);

            return task.ContinueWith(res => callback(task));
        }
        public IAsyncResult BeginDeleteCatalogBrochure(string environment , string catalogId, AsyncCallback callback, object state)
        {
            var connectionController = new ConnectionController(environment );
            var controller = new ResponseController(connectionController.ConnectionString);

            var sproc = new CatalogBrochureDeleteStoredProcedure();
            sproc.SprocParameters["@CatalogId"] = Convert.ToInt32(catalogId);

            var task = Task<TransactionResponse>.Factory.StartNew(r =>
                controller.ExecuteEntityTransaction<CatalogBrochureDeleteStoredProcedure, CatalogBrochure>(sproc), state);

            return task.ContinueWith(r => callback(task));
        }