Example #1
0
    protected void uxUpdateButton_Click(object sender, EventArgs e)
    {
        if (Page.IsValid)
        {
            Customer             customer     = DataAccessContext.CustomerRepository.GetOne(CustomerID);
            CustomerSubscription subscription = new CustomerSubscription();
            if (SubscriptionLevelID != uxSubscriptionLevel.SelectedValue)
            {
                subscription = subscription.GetCustomerSubscriptionByLevelID(uxSubscriptionLevel.SelectedValue, CustomerID);
                if (subscription != null)
                {
                    uxMessage.DisplayError(Resources.CustomerMessages.DuplicateCustomerSubscriptionError);
                    return;
                }
            }

            try
            {
                Update();
                PopulateControls();
                uxMessage.DisplayMessage(Resources.CustomerMessages.UpdateCustomerSubscriptionSuccess);
            }
            catch (Exception ex)
            {
                uxMessage.DisplayException(ex);
            }
        }
    }
Example #2
0
        public Migi.Framework.Models.ChangeResult RemoveCustomerSubscription(Guid subscriptionId, Guid userId)
        {
            Migi.Framework.Models.ChangeResult result = new Migi.Framework.Models.ChangeResult();

            CustomerSubscription subscription = _subscriptionAccess.LoadCustomerSubscription(subscriptionId);

            if (subscription == null)
            {
                result.AddErrorMessage("Could not load subscription");
            }
            else if (subscription.IsExpiredSubscription)
            {
                result.AddErrorMessage("Subscription is already removed");
            }

            if (result.IsSuccess)
            {
                subscription.ExpiresDate  = DateTime.UtcNow;
                subscription.DeleteDate   = DateTime.UtcNow;
                subscription.ChangeDate   = DateTime.UtcNow;
                subscription.ChangeUserId = userId;

                if (!_subscriptionAccess.SaveSubscription(subscription))
                {
                    result.AddErrorMessage("Could not save subscription");
                }
            }
            return(result);
        }
Example #3
0
 private void ShowAddForm(CustomerSubscription cs)
 {
     using (AddCustomerSubscriptionForm addForm = new AddCustomerSubscriptionForm(cs))
     {
         addForm.ShowDialog();
     }
 }
Example #4
0
 private void InitForm(CustomerSubscription cs)
 {
     txtFirstName.Text     = cs.FirstName;
     txtLastName.Text      = cs.LastName;
     txtPhone.Text         = cs.Phone;
     ddlSubscriptions.Text = cs.SubscriptionNumber;
     txtSessionsCount.Text = $"{cs.SessionsCount}";
 }
        public bool SaveSubscription(CustomerSubscription subscription)
        {
            using (SqlConnection connection = GetOpenConnection())
            {
                int rowsAffected = connection.Execute("spCustomerSubscriptionSaveSubscription", param: subscription.GetParametersForSave(), commandType: CommandType.StoredProcedure);

                return(rowsAffected > 0);
            }
        }
Example #6
0
    protected void uxAddToCartImageButton_Click(object sender, EventArgs e)
    {
        if (String.IsNullOrEmpty(ProductID))
        {
            ProductID = uxProductHidden.Value;
        }

        ProductSubscription subscriptionItem = new ProductSubscription(CurrentProduct.ProductID);

        if (subscriptionItem.IsSubscriptionProduct())
        {
            if (StoreContext.Customer.IsNull)
            {
                Response.Redirect("~/UserLogin.aspx?ReturnUrl=AddtoCart.aspx?ProductID=" + CurrentProduct.ProductID);
            }

            if (CustomerSubscription.IsContainsProductSubscriptionHigherLevel(
                    subscriptionItem.ProductSubscriptions[0].SubscriptionLevelID,
                    DataAccessContextDeluxe.CustomerSubscriptionRepository.GetCustomerSubscriptionsByCustomerID(StoreContext.Customer.CustomerID)))
            {
                Response.Redirect("AddShoppingCartNotComplete.aspx?ProductID=" + CurrentProduct.ProductID);
            }
        }

        if (!StoreContext.ShoppingCart.CheckCanAddItemToCart(CurrentProduct))
        {
            Response.Redirect("AddShoppingCartNotComplete.aspx?ProductID=" + CurrentProduct.ProductID);
        }

        if (StoreContext.CheckoutDetails.ContainsGiftRegistry())
        {
            Response.Redirect("AddShoppingCartNotComplete.aspx");
        }
        else
        {
            DataListItem item = uxList.Items[0];

            string errorMessage = String.Empty;
            if (VerifyValidInput(item, out errorMessage) &&
                IsMatchQuantity(item, out errorMessage))
            {
                AddItemToShoppingCart(item, out errorMessage);
            }

            if (!String.IsNullOrEmpty(errorMessage))
            {
                uxMessage.DisplayError(errorMessage);
                uxQuickViewButton.CommandArgument = "show";
            }
            else
            {
                uxMessage.ClearMessage();
                uxQuickViewButton.CommandArgument = "hide";
                uxUpdatePanel.Update();
            }
        }
    }
Example #7
0
        /// <summary>
        /// Cria uma assinatura
        /// </summary>
        /// <param name="customerSubscription">dados da assinatura</param>
        /// <returns>Assinatura criada com sucesso</returns>
        /// <see cref="http://api.boletosimples.com.br/reference/v1/customer_subscriptions/#criar-assinatura"/>
        public async Task <ApiResponse <CustomerSubscription> > PostAsync(CustomerSubscription customerSubscription)
        {
            var request = _requestBuilder.To(_client.Connection.GetBaseUri(), CUSTOMER_SUBSCRIPTION_API)
                          .WithMethod(HttpMethod.Post)
                          .AndOptionalContent(customerSubscription)
                          .Build();

            return(await _client.SendAsync <CustomerSubscription>(request));
        }
Example #8
0
        /// <summary>
        /// Atualizar uma assinatura
        /// </summary>
        /// <param name="customerSubscription">dados da assinatura</param>
        /// <param name="customerSubscriptionId">Id da assinatura</param>
        /// <see cref="http://api.boletosimples.com.br/reference/v1/customer_subscriptions/#atualizar-assinatura"/>
        /// <returns>Assinatura criada com sucesso</returns>
        public async Task <HttpResponseMessage> PutAsync(int customerSubscriptionId, CustomerSubscription customerSubscription)
        {
            var request = _requestBuilder.To(_client.Connection.GetBaseUri(), $"{CUSTOMER_SUBSCRIPTION_API}/{customerSubscriptionId}")
                          .WithMethod(HttpMethod.Put)
                          .AndOptionalContent(customerSubscription)
                          .Build();

            return(await _client.SendAsync(request).ConfigureAwait(false));
        }
        public CustomerSubscription LoadCustomerSubscriptionByCustomerAndSeries(Guid customerId, Guid comicBookSeriesId, DateTime searchDate)
        {
            CustomerSubscription subscription = null;

            using (SqlConnection connection = GetOpenConnection())
            {
                subscription = connection.Query <CustomerSubscription>("spCustomerSubscriptionGetCustomerSubscription", new { CustomerId = customerId, ComicBookSeriesId = comicBookSeriesId, SearchDate = searchDate }, commandType: CommandType.StoredProcedure).FirstOrDefault();
            }
            return(subscription);
        }
Example #10
0
        //method to create the appointment
        public ViewResult CreateAppointment()
        {
            CustomerSubscription custSub = new CustomerSubscription();

            ViewBag.period      = custSub.Periodicity;
            ViewBag.finDate     = DateTime.Now.ToString("yyyy-MM-dd");
            ViewBag.CustList    = getCustomersList(null);
            ViewBag.CLeanList   = getCleanersList(null);
            ViewBag.ServiceList = getServiceList(null);
            return(View("../Appointment/CreateAppointment"));
        }
Example #11
0
        public void DeleteCustomerSubscription(int idAppointment)
        {
            CustomerSubscription dbEntry = context.CustomerSubscription.
                                           FirstOrDefault(c => c.IdAppointment == idAppointment);

            if (dbEntry != null)
            {
                context.CustomerSubscription.Remove(dbEntry);
                context.SaveChanges();
            }
        }
    protected void uxAddItemButton_Command(object sender, CommandEventArgs e)
    {
        string  productID = e.CommandArgument.ToString();
        Product product   = DataAccessContext.ProductRepository.GetOne(
            uxLanguageControl.CurrentCulture, productID, SelectedStoreID);

        ProductSubscription subscriptionItem = new ProductSubscription(product.ProductID);

        if (subscriptionItem.IsSubscriptionProduct())
        {
            if (CustomerSubscription.IsContainsProductSubscriptionHigherLevel(
                    subscriptionItem.ProductSubscriptions[0].SubscriptionLevelID,
                    DataAccessContextDeluxe.CustomerSubscriptionRepository.GetCustomerSubscriptionsByCustomerID(SelectedCustomerID)))
            {
                uxMessage.DisplayError(
                    "Cannot add product to the cart. This customer already has higer product subscription level.");
                return;
            }
        }

        if (StoreContext.ShoppingCart.CheckCanAddItemToCart(product))
        {
            uxProductItemDetails.StoreID      = SelectedStoreID;
            uxProductItemDetails.CultureID    = uxLanguageControl.CurrentCulture.CultureID;
            uxProductItemDetails.ProductID    = productID;
            uxProductItemDetails.CurrencyCode = uxCurrencyControl.CurrentCurrencyCode;
            uxProductItemDetails.PopulateControls();
            uxAddItemPanel.Visible     = true;
            uxUpdateItemButton.Visible = false;
            uxAddItemButton.Visible    = true;
            uxAddItemButtonModalPopup.Show();

            if (uxProductItemDetails.IsProductKit(productID))
            {
                uxAddItemButton.Visible    = false;
                uxUpdateItemButton.Visible = false;
            }
        }
        else
        {
            if (product.FreeShippingCost)
            {
                uxMessage.DisplayError(
                    "Cannot add product to the cart. The shopping cart already has one or more product that not free shipping.");
            }
            else
            {
                uxMessage.DisplayError(
                    "Cannot add product to the cart. The shopping cart already has one or more product that is a free shipping product.");
            }
        }
    }
        public CustomerSubscription LoadCustomerSubscription(Guid customerSubscriptionId)
        {
            CustomerSubscription subscription = null;

            using (SqlConnection connection = GetOpenConnection())
            {
                List <CustomerSubscription> customerSubscriptions = connection.Query <CustomerSubscription>("spCustomerSubscriptionGetCustomerSubscription", new { CustomerSubscriptionId = customerSubscriptionId }, commandType: CommandType.StoredProcedure).ToList();

                subscription = customerSubscriptions.FirstOrDefault();
            }

            return(subscription);
        }
Example #14
0
    private void PopulateControls()
    {
        Customer customer = DataAccessContext.CustomerRepository.GetOne(CustomerID);

        uxUserNameLabel.Text = customer.UserName;
        CustomerSubscription subscription = new CustomerSubscription();

        uxSubscriptionLevel.SelectedValue = SubscriptionLevelID;
        uxSubscriptionLevelHidden.Value   = SubscriptionLevelID;

        uxStartDateCalendarPopup.SelectedDate  = subscription.GetCustomerSubscriptionByLevelID(SubscriptionLevelID, CustomerID).StartDate;
        uxExpireDateCalendarPopup.SelectedDate = subscription.GetCustomerSubscriptionByLevelID(SubscriptionLevelID, CustomerID).EndDate;
        uxIsActiveCheck.Checked = subscription.GetCustomerSubscriptionByLevelID(SubscriptionLevelID, CustomerID).IsActive;
    }
Example #15
0
    private void Update()
    {
        Customer             customer     = DataAccessContext.CustomerRepository.GetOne(CustomerID);
        CustomerSubscription subscription = new CustomerSubscription();

        subscription = subscription.GetCustomerSubscriptionByLevelID(uxSubscriptionLevel.SelectedValue, CustomerID);

        IList <CustomerSubscription> customerSubscriptionList = DataAccessContextDeluxe.CustomerSubscriptionRepository.GetCustomerSubscriptionsByCustomerID(CustomerID);

        if (subscription != null)
        {
            subscription.StartDate = uxStartDateCalendarPopup.SelectedDate;
            subscription.EndDate   = uxExpireDateCalendarPopup.SelectedDate;
            subscription.IsActive  = uxIsActiveCheck.Checked;

            int index = -1;
            for (int i = 0; i < customerSubscriptionList.Count; i++)
            {
                if (customerSubscriptionList[i].SubscriptionLevelID == uxSubscriptionLevelHidden.Value)
                {
                    index = i;
                }
            }

            customerSubscriptionList.RemoveAt(index);
            customerSubscriptionList.Add(subscription);
        }
        else
        {
            subscription                     = new CustomerSubscription();
            subscription.StartDate           = uxStartDateCalendarPopup.SelectedDate;
            subscription.EndDate             = uxExpireDateCalendarPopup.SelectedDate;
            subscription.SubscriptionLevelID = uxSubscriptionLevel.SelectedValue;
            subscription.IsActive            = uxIsActiveCheck.Checked;

            int index = -1;
            for (int i = 0; i < customerSubscriptionList.Count; i++)
            {
                if (customerSubscriptionList[i].SubscriptionLevelID == uxSubscriptionLevelHidden.Value)
                {
                    index = i;
                }
            }

            customerSubscriptionList.RemoveAt(index);
            customerSubscriptionList.Add(subscription);
        }
        DataAccessContextDeluxe.CustomerSubscriptionRepository.Save(customer.CustomerID, customerSubscriptionList);
        SubscriptionLevelID = uxSubscriptionLevel.SelectedValue;
    }
Example #16
0
        public async Task Create_CustomerSubscription_with_success()
        {
            // Arrange
            var CustomerSubscription = new CustomerSubscription(1, 1999.55m, "Any Subscription");

            // Act
            var response = await Client.CustomerSubscriptions.PostAsync(CustomerSubscription).ConfigureAwait(false);

            var sucessResponse = await response.GetSuccessResponseAsync().ConfigureAwait(false);

            // Assert
            Assert.That(response.IsSuccess, Is.True);
            Assert.That(sucessResponse, Is.Not.Null);
        }
Example #17
0
    protected void uxAddToCartImageButton_Click(object sender, EventArgs e)
    {
        ProductSubscription subscriptionItem = new ProductSubscription(CurrentProduct.ProductID);

        if (subscriptionItem.IsSubscriptionProduct())
        {
            if (StoreContext.Customer.IsNull)
            {
                string returnUrl = "AddtoCart.aspx?ProductID=" + CurrentProduct.ProductID;
                Response.Redirect("~/UserLogin.aspx?ReturnUrl=" + returnUrl);
            }

            if (CustomerSubscription.IsContainsProductSubscriptionHigherLevel(
                    subscriptionItem.ProductSubscriptions[0].SubscriptionLevelID,
                    DataAccessContextDeluxe.CustomerSubscriptionRepository.GetCustomerSubscriptionsByCustomerID(StoreContext.Customer.CustomerID)))
            {
                Response.Redirect("AddShoppingCartNotComplete.aspx?ProductID=" + CurrentProduct.ProductID);
            }
        }

        if (!StoreContext.ShoppingCart.CheckCanAddItemToCart(CurrentProduct))
        {
            Response.Redirect("AddShoppingCartNotComplete.aspx?ProductID=" + CurrentProduct.ProductID);
        }

        if (StoreContext.CheckoutDetails.ContainsGiftRegistry())
        {
            Response.Redirect("AddShoppingCartNotComplete.aspx");
        }
        else
        {
            string errorMessage = String.Empty;
            if (VerifyValidInput(out errorMessage))
            {
                if (IsMatchQuantity())
                {
                    AddItemToShoppingCart();
                }
            }
            else
            {
                if (errorMessage != String.Empty)
                {
                    uxMessage.Text       = errorMessage;
                    uxMessageDiv.Visible = true;
                }
            }
        }
    }
Example #18
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (ProductID != "0")
        {
            Product product = DataAccessContext.ProductRepository.GetOne(StoreContext.Culture, ProductID, StoreID);

            if (product == NullProduct.Null || !product.IsEnabled)
            {
                uxProductNotAvailableMessagePanel.Visible = true;
                return;
            }

            ProductSubscription subscriptionItem = new ProductSubscription(product.ProductID);

            if (subscriptionItem.IsSubscriptionProduct())
            {
                if (StoreContext.Customer.IsNull)
                {
                    Response.Redirect("~/UserLogin.aspx?ReturnUrl=AddtoCart.aspx?ProductID=" + product.ProductID);
                }

                if (CustomerSubscription.IsContainsProductSubscriptionHigherLevel(
                        subscriptionItem.ProductSubscriptions[0].SubscriptionLevelID,
                        DataAccessContextDeluxe.CustomerSubscriptionRepository.GetCustomerSubscriptionsByCustomerID(StoreContext.Customer.CustomerID)))
                {
                    Response.Redirect("AddShoppingCartNotComplete.aspx?ProductID=" + product.ProductID);
                }
            }

            if (!StoreContext.ShoppingCart.CheckCanAddItemToCart(product))
            {
                Response.Redirect("AddShoppingCartNotComplete.aspx?ProductID=" + product.ProductID);
            }

            if (StoreContext.CheckoutDetails.ContainsGiftRegistry())
            {
                Response.Redirect("AddShoppingCartNotComplete.aspx");
            }
            else
            {
                AddItemToShoppingCart(product);
            }
        }
        else
        {
            uxProductNotExistMessagePanel.Visible = true;
        }
    }
Example #19
0
    private void AddNew()
    {
        Customer customer = DataAccessContext.CustomerRepository.GetOne(CustomerID);

        IList <CustomerSubscription> subscriptionList = DataAccessContextDeluxe.CustomerSubscriptionRepository.GetCustomerSubscriptionsByCustomerID(CustomerID);

        CustomerSubscription subscription = new CustomerSubscription();

        subscription.StartDate           = uxStartDateCalendarPopup.SelectedDate;
        subscription.EndDate             = uxExpireDateCalendarPopup.SelectedDate;
        subscription.SubscriptionLevelID = uxSubscriptionLevel.SelectedValue;
        subscription.IsActive            = uxIsActiveCheck.Checked;
        subscriptionList.Add(subscription);
        DataAccessContext.CustomerRepository.Save(customer);
        DataAccessContextDeluxe.CustomerSubscriptionRepository.Save(customer.CustomerID, subscriptionList);
    }
        public void TestCreateAndDeleteCustomerSubscription()
        {
            RunTest((client) =>
            {
                CustomerSubscription parameter = new CustomerSubscription(
                    id: $"subscriptions/{TestSubscriptionID}/resourceGroups/{TestResourceGroupName}/providers/Microsoft.AzureStack/registrations/{TestRegistrationName}/customersubscriptions/{TestUserSubscriptionName}",
                    name: TestUserSubscriptionName,
                    type: "Microsoft.AzureStack/registrations/customersubscriptions",
                    tenantId: TestTenantID
                    );

                var subscription = client.CustomerSubscriptions.Create(TestResourceGroupName, TestRegistrationName, TestUserSubscriptionName, parameter);

                client.CustomerSubscriptions.Delete(TestResourceGroupName, TestRegistrationName, TestUserSubscriptionName);
            });
        }
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            CustomerSubscription = await _context.CustomerSubscriptions
                                   .Include(s => s.Service)
                                   .Include(s => s.Customer).FirstOrDefaultAsync(m => m.CustomerSubscriptionID == id);

            if (CustomerSubscription == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Example #22
0
        public async Task Get_CustomerSubscription_information_with_success()
        {
            // Arrange
            var CustomerSubscription = new CustomerSubscription(1, 9999.55m, "Any Subscription");
            var responseCreate       = await Client.CustomerSubscriptions.PostAsync(CustomerSubscription).ConfigureAwait(false);

            var sucessCreateResponse = await responseCreate.GetSuccessResponseAsync().ConfigureAwait(false);

            // Act
            var response = await Client.CustomerSubscriptions.GetAsync(sucessCreateResponse.Id).ConfigureAwait(false);

            var sucessResponse = await response.GetSuccessResponseAsync().ConfigureAwait(false);

            // Assert
            Assert.That(response.IsSuccess, Is.True);
            Assert.That(sucessResponse.Amount, Is.EqualTo(9999.55m));
        }
Example #23
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            CustomerSubscription = await _context.CustomerSubscriptions.FindAsync(id);

            if (CustomerSubscription != null)
            {
                _context.CustomerSubscriptions.Remove(CustomerSubscription);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
Example #24
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            CustomerSubscription = await _context.CustomerSubscriptions
                                   .Include(s => s.Service)
                                   .Include(s => s.Customer).FirstOrDefaultAsync(m => m.CustomerSubscriptionID == id);

            if (CustomerSubscription == null)
            {
                return(NotFound());
            }
            ViewData["ServiceID"]  = new SelectList(_context.PremiumServices, "ServiceID", "ServiceName");
            ViewData["CustomerID"] = new SelectList(_context.Customers, "CustomerID", "CustomerName");
            return(Page());
        }
Example #25
0
 public void SaveCustomerSubscription(CustomerSubscription customerSubscription)
 {
     if (customerSubscription.IdSubscription == 0)
     {
         context.CustomerSubscription.Add(customerSubscription);
     }
     else
     {
         CustomerSubscription dbEntry = context.CustomerSubscription.
                                        FirstOrDefault(c => c.IdSubscription == customerSubscription.IdSubscription);
         if (dbEntry != null)
         {
             dbEntry.Periodicity   = customerSubscription.Periodicity;
             dbEntry.FinishDate    = customerSubscription.FinishDate;
             dbEntry.IdAppointment = customerSubscription.IdAppointment;
         }
     }
     context.SaveChanges();
 }
Example #26
0
        public async Task Given_input_json_of_model_CustomerSubscription_should_be_serialize_and_desesialize_right()
        {
            // Arrange
            CustomerSubscription firstCustomerSubscription  = null;
            CustomerSubscription secondCustomerSubscription = null;

            // Act && Assert
            Assert.DoesNotThrowAsync(async() =>
            {
                firstCustomerSubscription = await Task.FromResult(JsonConvert.DeserializeObject <CustomerSubscription>(JsonConstants.CurstomerSubscription))
                                            .ConfigureAwait(false);

                var customerSubscriptionJson = await Task.FromResult(JsonConvert.SerializeObject(firstCustomerSubscription))
                                               .ConfigureAwait(false);

                secondCustomerSubscription = await Task.FromResult(JsonConvert.DeserializeObject <CustomerSubscription>(customerSubscriptionJson))
                                             .ConfigureAwait(false);
            });

            // Other Asserts
            firstCustomerSubscription.Should().BeEquivalentTo(secondCustomerSubscription);
        }
Example #27
0
        public async Task Delete_CustomerSubscription_with_sucess()
        {
            // Arrange
            var CustomerSubscription = new CustomerSubscription(1, 300.55m, "Any Subscription");
            var responseCreate       = await Client.CustomerSubscriptions.PostAsync(CustomerSubscription).ConfigureAwait(false);

            var sucessCreateResponse = await responseCreate.GetSuccessResponseAsync().ConfigureAwait(false);

            var responseList = await Client.CustomerSubscriptions.GetAsync(sucessCreateResponse.Id).ConfigureAwait(false);

            var sucessResponseList = await responseList.GetSuccessResponseAsync().ConfigureAwait(false);

            // Act
            var deleteSuccessResponse = await Client.CustomerSubscriptions.DeleteAsync(sucessResponseList.Id).ConfigureAwait(false);

            var content = await deleteSuccessResponse.Content.ReadAsStringAsync().ConfigureAwait(false);

            // Assert
            Assert.That(deleteSuccessResponse.IsSuccessStatusCode, Is.True);
            Assert.That(deleteSuccessResponse.StatusCode, Is.EqualTo(HttpStatusCode.NoContent));
            Assert.That(content, Is.Empty);
        }
Example #28
0
        private void Instantiate(CustomerSubscription subscriptionDl)
        {
            this.HasData = false;

            if (subscriptionDl != null)
            {
                this.HasData           = true;
                this.SubscriptionId    = subscriptionDl.CustomerSubscriptionId;
                this.CustomerId        = subscriptionDl.CustomerId;
                this.ComicBookSeriesId = subscriptionDl.ComicBookSeriesId;

                this.PublisherName = subscriptionDl.PublisherName;
                this.SeriesTitle   = subscriptionDl.SeriesTitle;

                this.EffectiveDate = subscriptionDl.EffectiveDate;
                this.ExpiresDate   = subscriptionDl.ExpiresDate;

                this.CreateDate   = subscriptionDl.CreateDate;
                this.CreateUserId = subscriptionDl.CreateUserId;
                this.ChangeUserId = subscriptionDl.ChangeUserId;
                this.ChangeDate   = subscriptionDl.ChangeDate;
                this.DeleteDate   = subscriptionDl.DeleteDate;
            }
        }
Example #29
0
        public async Task Update_CustomerSubscription_with_success()
        {
            // Arrange
            var CustomerSubscription = new CustomerSubscription(1, 150.55m, "Any Subscription");
            var createResponse       = await Client.CustomerSubscriptions.PostAsync(CustomerSubscription).ConfigureAwait(false);

            var createSucessResponse = await createResponse.GetSuccessResponseAsync().ConfigureAwait(false);

            var subscription = new CustomerSubscription(1, 301.10m, "Other Subscription")
            {
                Cycle = Constants.Cycles.BIMONTHLY,
                Id    = createSucessResponse.Id,
            };

            // Act
            var updateResponse = await Client.CustomerSubscriptions.PutAsync(createSucessResponse.Id, subscription).ConfigureAwait(false);

            var content = await updateResponse.Content.ReadAsStringAsync().ConfigureAwait(false);

            // Assert
            Assert.That(createResponse.IsSuccess, Is.True);
            Assert.That(updateResponse.IsSuccessStatusCode, Is.True);
            Assert.That(content, Is.Empty);
        }
Example #30
0
 public static CustomerSubscription CreateCustomerSubscription(int customerID, int subscriptionID, int subscriptionStatusID, global::System.DateTime startDate, global::System.DateTime expireDate)
 {
     CustomerSubscription customerSubscription = new CustomerSubscription();
     customerSubscription.CustomerID = customerID;
     customerSubscription.SubscriptionID = subscriptionID;
     customerSubscription.SubscriptionStatusID = subscriptionStatusID;
     customerSubscription.StartDate = startDate;
     customerSubscription.ExpireDate = expireDate;
     return customerSubscription;
 }
Example #31
0
        public CustomerSubscription GetCustomerSubscription(int CustomerID, int SubscriptionID)
        {
            var result = new CustomerSubscription();

            using (var reader = GetContext().GetReader(@"
                    SELECT
                        SubscriptionID,
                        CustomerID,
                        IsActive,
                        StartDate,
                        ExpireDate
                    FROM CustomerSubscriptions
                    WHERE
                        CustomerID = {0}
                        AND SubscriptionID = {1}
                ", CustomerID, SubscriptionID))
            {
                if (!reader.Read()) return null;

                result.CustomerID = reader.GetInt32("CustomerID");
                result.SubscriptionID = reader.GetInt32("SubscriptionID");
                result.IsActive = reader.GetBoolean("IsActive");
                result.StartDate = reader.GetDateTime("StartDate");
                result.ExpirationDate = reader.GetDateTime("ExpireDate");
            }

            return result;
        }
Example #32
0
 public Subscription(CustomerSubscription subscriptionDl)
 {
     Instantiate(subscriptionDl);
 }
Example #33
0
 public void AddToCustomerSubscriptions(CustomerSubscription customerSubscription)
 {
     base.AddObject("CustomerSubscriptions", customerSubscription);
 }
Example #34
0
        public CustomerSubscription GetCustomerSubscription(int CustomerID, int SubscriptionID)
        {
            var result = new CustomerSubscription();

            var response = GetContext().GetSubscription(new GetSubscriptionRequest()
            {
                CustomerID = CustomerID,
                SubscriptionID = SubscriptionID
            });
            if(response == null) return null;

            result.CustomerID = CustomerID;
            result.SubscriptionID = SubscriptionID;
            result.IsActive = (response.Status == Exigo.Api.WebService.SubscriptionStatus.Active);
            result.StartDate = response.StartDate;
            result.ExpirationDate = response.ExpireDate;

            return result;
        }
Example #35
0
        public CustomerSubscription GetCustomerSubscription(int CustomerID, int SubscriptionID)
        {
            var result = new CustomerSubscription();

            var response = GetContext().CustomerSubscriptions
                .Where(c => c.CustomerID == CustomerID)
                .Where(c => c.SubscriptionID == SubscriptionID)
                .FirstOrDefault();
            if(response == null) return null;

            result.CustomerID = CustomerID;
            result.SubscriptionID = SubscriptionID;
            result.IsActive = (response.SubscriptionStatus.SubscriptionStatusID == 1);
            result.StartDate = response.StartDate;
            result.ExpirationDate = response.ExpireDate;

            return result;
        }