Beispiel #1
0
        public ElectronicProduct GetProductDetail(long productId)
        {
            IElectronicProductRepository electronicProductRepository = new ElectronicProductRepository();

            var cdProduct = electronicProductRepository.GetById(productId);

            return(cdProduct);
        }
Beispiel #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindProduct();

                if (RegistrationFlow != null && RegistrationFlow.ProductId > 0)
                {
                    IElectronicProductRepository electronicProductRepository = new ElectronicProductRepository();
                    var product = electronicProductRepository.GetById(RegistrationFlow.ProductId);
                    if (ShippingOptionId.HasValue)
                    {
                        Page.ClientScript.RegisterStartupScript(typeof(string), "js_SetProduct",
                                                                "SelectProduct('" + RegistrationFlow.ProductId + "','" + product.Price + "',false);", true);
                    }
                    else
                    {
                        Page.ClientScript.RegisterStartupScript(typeof(string), "js_SetProduct",
                                                                "SelectProduct('" + RegistrationFlow.ProductId + "','" + product.Price + "',true);", true);
                    }
                }
            }
        }
        private bool PaymentViaSourceCode()
        {
            var organizationRoleUser = GetOrganizationRoleUser();

            var orderables     = new List <IOrderable>();
            var packageTestIds = new List <long>();

            if (PackageId > 0)
            {
                var packageRepository = IoC.Resolve <IEventPackageRepository>();
                var package           = packageRepository.GetByEventAndPackageIds(EventId.Value, PackageId);
                if (package != null)
                {
                    packageTestIds = package.Tests.Select(t => t.Test.Id).ToList();
                }

                orderables.Add(package);
            }

            var independentTestIds = !packageTestIds.IsNullOrEmpty() ? TestIds.Where(t => !packageTestIds.Contains(t)).Select(t => t).ToList() : TestIds;

            if (!independentTestIds.IsNullOrEmpty())
            {
                var eventTestRepository = IoC.Resolve <IEventTestRepository>();
                orderables.AddRange(eventTestRepository.GetByEventAndTestIds(EventId.Value, independentTestIds));
            }

            if (ProductId.HasValue && ProductId.Value > 0)
            {
                IUniqueItemRepository <ElectronicProduct> itemRepository = new ElectronicProductRepository();
                orderables.Add(itemRepository.GetById(ProductId.Value));
            }

            if (orderables.IsNullOrEmpty())
            {
                return(false);
            }

            Core.Finance.Domain.Order order = null;
            EventCustomer             eventCustomer;

            try
            {
                order = GetOrder();
                if (order == null)
                {
                    eventCustomer = SaveEventCustomer(organizationRoleUser);
                }
                else
                {
                    eventCustomer = UpdateEventCustomer(organizationRoleUser);
                }
            }
            catch
            {
                eventCustomer = SaveEventCustomer(organizationRoleUser);
            }

            SourceCode sourceCode;

            if (SourceCodeId > 0)
            {
                sourceCode = new SourceCode
                {
                    Id          = SourceCodeId,
                    CouponCode  = SourceCode,
                    CouponValue = SourceCodeAmount
                }
            }
            ;
            else
            {
                sourceCode = null;
            }

            if (ShippingDetail != null)
            {
                IShippingController shippingController = new ShippingController();
                ShippingDetail = shippingController.OrderShipping(ShippingDetail);
            }

            IOrderController orderController        = new OrderController();
            bool             indentedLineItemsAdded = false;

            // TODO: applying hook to the system all the indented line items will be attached to the first order item.
            foreach (var orderable in orderables)
            {
                if (!indentedLineItemsAdded)
                {
                    orderController.AddItem(orderable, 1, organizationRoleUser.Id, organizationRoleUser.Id,
                                            sourceCode,
                                            eventCustomer, ShippingDetail, OrderStatusState.FinalSuccess);
                    indentedLineItemsAdded = true;
                }
                else
                {
                    orderController.AddItem(orderable, 1, organizationRoleUser.Id, organizationRoleUser.Id,
                                            OrderStatusState.FinalSuccess);
                }
            }

            if (order == null)
            {
                order = orderController.PlaceOrder(OrderType.Retail, organizationRoleUser.Id);
            }
            else
            {
                order = orderController.ActivateOrder(order);
            }

            SaveProductShippingDetail(order);
            return(true);
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (EventId.HasValue)
     {
         OrderSummaryControl.EventId             = EventId.Value;
         OrderSummaryControl.RoleId              = (long)Roles.Technician;
         OrderSummaryControl.PackageId           = PackageId.HasValue ? PackageId.Value : 0;
         OrderSummaryControl.TestIds             = TestIds;
         OrderSummaryControl.IsSourceCodeApplied = SourceCodeId > 0;
         OrderSummaryControl.SourceCodeAmount    = SourceCodeAmount;
         if (!AppointmentSlotIds.IsNullOrEmpty())
         {
             var slotService = IoC.Resolve <IEventSchedulingSlotService>();
             var slot        = slotService.GetHeadSlotintheChain(AppointmentSlotIds);
             OrderSummaryControl.AppointmentTime = slot.StartTime.ToString("hh:mm tt");
         }
         if (ProductId.HasValue && ProductId.Value > 0)
         {
             IUniqueItemRepository <ElectronicProduct> itemRepository = new ElectronicProductRepository();
             var product = itemRepository.GetById(ProductId.Value);
             OrderSummaryControl.ProductName  = product.Name;
             OrderSummaryControl.ProductPrice = product.Price;
         }
         if (ShippingDetail != null && ShippingDetail.ShippingOption != null && ShippingDetail.ShippingOption.Id > 0)
         {
             IUniqueItemRepository <ShippingOption> itemRepository = new ShippingOptionRepository();
             var shippingOption = itemRepository.GetById(ShippingDetail.ShippingOption.Id);
             OrderSummaryControl.ShippingOption      = shippingOption.Name;
             OrderSummaryControl.ShippingOptionPrice = ShippingDetail.ActualPrice;
         }
     }
     if (!IsPostBack)
     {
         if (EventId.HasValue)
         {
             hfEventID.Value = EventId.Value.ToString();
         }
         else
         {
             SetAndDisplayErrorMessage("OOPS! Some error occured while saving details.");
             return;
         }
         if (TotalAmount.HasValue)
         {
             hfNetPayableAmount.Value = TotalAmount.ToString();
         }
         else
         {
             SetAndDisplayErrorMessage("OOPS! Some error occured while saving details.");
             return;
         }
         EligibilityIdHiddenField.Value = EligibilityId.ToString();
         ChargeCardIdHiddenField.Value  = ChargeCardId.ToString();
         if (ChargeCardId > 0)
         {
             GetCreditCardDataByChargeCardId(ChargeCardId);
         }
         BindJavaScriptEvents();
     }
     else
     {
         if (PostBackAction())
         {
             EligibilityId = Convert.ToInt64(EligibilityIdHiddenField.Value);
             ChargeCardId  = Convert.ToInt64(ChargeCardIdHiddenField.Value);
             PersistPaymentData();
         }
     }
 }