예제 #1
0
        private bool SetCustomerDetail()
        {
            IUniqueItemRepository <EventCustomer> eventCustomerRepository = new EventCustomerRepository();
            var eventCustomer = eventCustomerRepository.GetById(EventCustomerId);

            if (eventCustomer != null)
            {
                CustomerId = eventCustomer.CustomerId;
                EventId    = eventCustomer.EventId;
                var organizationRoleUserRepository = IoC.Resolve <IOrganizationRoleUserRepository>();
                var orgRoleUser = organizationRoleUserRepository.GetOrganizationRoleUser(eventCustomer.DataRecorderMetaData.DataRecorderCreator.Id);

                EventRegisteredBy = (Roles)Enum.Parse(typeof(Roles), orgRoleUser.RoleId.ToString());

                speventid.InnerText = EventId.ToString();

                if (Customer != null && Customer.Address != null)
                {
                    spcustomerdetail.InnerText = " " + "-" + " " + Customer.Name + "(ID:" + Customer.CustomerId + ")";
                }

                var eventService            = IoC.Resolve <IEventService>();
                var eventBasicInfoViewModel = eventService.GetEventBasicInfoFor(eventCustomer.EventId);

                speventid.InnerText  = EventId.ToString();
                sphostname.InnerText = eventBasicInfoViewModel.HostName;
                spaddress.InnerText  =
                    CommonCode.AddressSingleLine(eventBasicInfoViewModel.HostAddress.StreetAddressLine1,
                                                 eventBasicInfoViewModel.HostAddress.StreetAddressLine2,
                                                 eventBasicInfoViewModel.HostAddress.City,
                                                 eventBasicInfoViewModel.HostAddress.State,
                                                 eventBasicInfoViewModel.HostAddress.ZipCode);

                if (eventCustomer.AppointmentId.HasValue)
                {
                    var appointmentRepository = IoC.Resolve <IAppointmentRepository>();
                    var appointment           = appointmentRepository.GetById(eventCustomer.AppointmentId.Value);
                    spapptime.InnerText = appointment.StartTime.ToShortTimeString();
                }

                speventdate.InnerText  = eventBasicInfoViewModel.EventDate.ToShortDateString();
                ViewState["EventDate"] = eventBasicInfoViewModel.EventDate.ToShortDateString();


                IOrderRepository orderRepository = new OrderRepository();
                var order = orderRepository.GetOrder(CustomerId.Value, EventId.Value);
                if (order != null && !order.OrderDetails.IsEmpty())
                {
                    hfPackageCost.Value = order.OrderDetails.Where(od =>
                                                                   (od.DetailType == OrderItemType.EventPackageItem && od.IsCompleted) ||
                                                                   (od.DetailType == OrderItemType.EventTestItem && od.IsCompleted))
                                          .Sum(od => od.Price).ToString();

                    sppackagecost.InnerText =
                        order.OrderDetails.Where(od =>
                                                 (od.DetailType == OrderItemType.EventPackageItem && od.IsCompleted) ||
                                                 (od.DetailType == OrderItemType.EventTestItem && od.IsCompleted))
                        .Sum(od => od.Price).ToString("C2");

                    OrderId = order.Id;
                    SetRefundRequestAmount(OrderId);
                    SetPaymentDetails(order);

                    IOrderController orderController = new OrderController();
                    var orderDetail = orderController.GetActiveOrderDetail(order);
                    IOrderItemRepository orderItemRepository = new OrderItemRepository();
                    var orderItem = orderItemRepository.GetOrderItem(orderDetail.OrderItemId);
                    if (orderItem is EventPackageItem)
                    {
                        var eventPackageItem = orderItem as EventPackageItem;

                        var itemRepository = IoC.Resolve <IEventPackageRepository>();
                        var eventPackage   = itemRepository.GetById(eventPackageItem.ItemId);
                        PackageId = eventPackage.PackageId;
                    }
                    if (orderDetail.SourceCodeOrderDetail != null)
                    {
                        if (Customer != null)
                        {
                            ViewState["DateApplied"] = Customer.DateCreated;
                        }

                        ISourceCodeRepository sourceCodeRepository = new SourceCodeRepository();
                        var sourceCode =
                            sourceCodeRepository.GetSourceCodeById(orderDetail.SourceCodeOrderDetail.SourceCodeId);
                        spcoupon.InnerText = sourceCode.CouponCode;

                        if (!string.IsNullOrEmpty(sourceCode.CouponCode))
                        {
                            rbtreplaceexisting.Checked  = true;
                            hfcurrentcoupon.Value       = sourceCode.CouponCode;
                            hfcurrentcouponamount.Value = orderDetail.SourceCodeOrderDetail.Amount.ToString("N2");
                        }
                        else
                        {
                            rbtapplycoupon.Checked = true;
                        }
                    }
                    else
                    {
                        spcoupon.InnerText     = "N/A";
                        rbtapplycoupon.Checked = true;
                    }
                }
                return(true);
            }
            return(false);
        }