public EventCustomerOrderSummaryModel GetEventCustomerOrderSummaryModel(TempCart tempCart, OrderPlaceEditModel orderPlaceEditModel, SourceCodeApplyEditModel sourceCodeModel) { if (tempCart == null) { return(new EventCustomerOrderSummaryModel()); } Event theEvent = null; Host eventHost = null; if (tempCart.EventId.HasValue) { theEvent = _eventRepository.GetById(tempCart.EventId.Value); eventHost = _hostRepository.GetHostForEvent(tempCart.EventId.Value); } EventSchedulingSlot appointment = null; if (tempCart.AppointmentId.HasValue) { appointment = _slotRepository.GetbyId(tempCart.AppointmentId.Value); } EventPackage eventPackage = null; if (orderPlaceEditModel.SelectedPackageId > 0) { eventPackage = _eventPackageRepository.GetById(orderPlaceEditModel.SelectedPackageId); } IEnumerable <EventTest> eventTests = null; if (orderPlaceEditModel.SelectedTestIds != null && orderPlaceEditModel.SelectedTestIds.Count() > 0) { eventTests = _eventTestRepository.GetbyIds(orderPlaceEditModel.SelectedTestIds); } IEnumerable <ElectronicProduct> products = null; if (orderPlaceEditModel.SelectedProductIds != null && orderPlaceEditModel.SelectedProductIds.Count() > 0) { products = _productRepository.GetByIds(orderPlaceEditModel.SelectedProductIds); } ShippingOption shippingOption = null; if (orderPlaceEditModel.SelectedShippingOptionId > 0) { shippingOption = _shippingOptionRepository.GetById(orderPlaceEditModel.SelectedShippingOptionId); } Order order = null; if (tempCart.IsCompleted) { order = _orderRepository.GetOrder(tempCart.CustomerId.Value, tempCart.EventId.Value); } return(_eventCustomerSummaryModelFactory.Create(theEvent, eventHost, appointment, eventPackage, eventTests, products, shippingOption, sourceCodeModel, order, tempCart.ShippingId)); }
public bool Delete(EventSchedulingSlot slot) { using (var adapter = PersistenceLayer.GetDataAccessAdapter()) { var entity = Mapper.Map <EventSchedulingSlot, EventSchedulingSlotEntity>(slot); return(adapter.DeleteEntity(entity)); } }
public EventSchedulingSlot Save(EventSchedulingSlot slot) { using (var adapter = PersistenceLayer.GetDataAccessAdapter()) { var entity = Mapper.Map <EventSchedulingSlot, EventSchedulingSlotEntity>(slot); if (!adapter.SaveEntity(entity, true)) { throw new PersistenceFailureException(); } return(Mapper.Map <EventSchedulingSlotEntity, EventSchedulingSlot>(entity)); } }
public EventCustomerOrderSummaryModel GetEventCustomerOrderSummaryModel(TempCart tempCart, SourceCodeApplyEditModel sourceCodeModel = null) { if (tempCart == null) { return(new EventCustomerOrderSummaryModel()); } Event theEvent = null; Host eventHost = null; if (tempCart.EventId.HasValue) { theEvent = _eventRepository.GetById(tempCart.EventId.Value); eventHost = _hostRepository.GetHostForEvent(tempCart.EventId.Value); } EventSchedulingSlot appointment = null; if (tempCart.AppointmentId.HasValue) { appointment = _slotRepository.GetbyId(tempCart.AppointmentId.Value); } EventPackage eventPackage = null; if (tempCart.EventPackageId.HasValue) { eventPackage = _eventPackageRepository.GetById(tempCart.EventPackageId.Value); } IEnumerable <EventTest> eventTests = null; var testIds = new List <long>(); if (!string.IsNullOrEmpty(tempCart.TestId)) { string[] testIdStrings = tempCart.TestId.Split(new[] { ',' }); foreach (var testIdString in testIdStrings) { int i = 0; if (int.TryParse(testIdString, out i)) { testIds.Add(i); } } } if (testIds.Count > 0) { eventTests = _eventTestRepository.GetbyIds(testIds); } IEnumerable <ElectronicProduct> products = null; var productIds = new List <long>(); if (!string.IsNullOrEmpty(tempCart.ProductId)) { string[] productIdStrings = tempCart.ProductId.Split(new[] { ',' }); foreach (var productIdIdString in productIdStrings) { int i = 0; if (int.TryParse(productIdIdString, out i)) { productIds.Add(i); } } } if (productIds.Count > 0) { products = _productRepository.GetByIds(productIds); } ShippingOption shippingOption = null; if (tempCart.ShippingId.HasValue && tempCart.ShippingId.Value > 0) { shippingOption = _shippingOptionRepository.GetById(tempCart.ShippingId.Value); } SourceCodeApplyEditModel applySourceCodemodel = sourceCodeModel ?? GetSourceCodeApplied(tempCart); Order order = null; if (tempCart.IsCompleted) { order = _orderRepository.GetOrder(tempCart.CustomerId.Value, tempCart.EventId.Value); } return(_eventCustomerSummaryModelFactory.Create(theEvent, eventHost, appointment, eventPackage, eventTests, products, shippingOption, applySourceCodemodel, order, tempCart.ShippingId)); }
public EventCustomerOrderSummaryModel Create(Event eventInfo, Host host, EventSchedulingSlot appointmentSlot, EventPackage eventPackage, IEnumerable <EventTest> eventTests, IEnumerable <Product> products, ShippingOption shippingOption, SourceCodeApplyEditModel sourceCodeApplyEditModel, Order order, long?shippingOptionId) { var model = new EventCustomerOrderSummaryModel(); if (eventInfo != null) { model.EventId = eventInfo.Id; model.EventType = eventInfo.EventType; model.EventDate = eventInfo.EventDate; model.Host = host.OrganizationName; model.Address = Mapper.Map <Address, AddressViewModel>(host.Address); model.CaptureInsuranceId = eventInfo.CaptureInsuranceId; } if (appointmentSlot != null) { model.AppointmentTime = appointmentSlot.StartTime; } decimal totalPrice = 0; if (eventPackage != null) { model.Package = new OrderedPair <string, decimal>(eventPackage.Package.Name, eventPackage.Price); model.PackageTest = eventPackage.Tests.Select(ept => ept.Test.Name).ToArray(); totalPrice = eventPackage.Price; } if (eventTests != null) { model.AdditionalTests = eventTests.Select(et => new OrderedPair <string, decimal>(et.Test.Name, eventPackage != null ? et.WithPackagePrice : et.Price)).ToArray(); var testPrice = eventTests.Select(et => eventPackage != null ? et.WithPackagePrice : et.Price).Sum(); totalPrice += testPrice; } if (products != null) { model.Product = products.Select(p => new OrderedPair <string, decimal>(p.Name, p.Price)).ToArray(); var productPrice = products.Select(p => p.Price).Sum(); totalPrice += productPrice; } if (shippingOption != null) { model.ShippingOption = new OrderedPair <string, decimal>(shippingOption.Name, shippingOption.Price); totalPrice += shippingOption.Price; } model.TotalPrice = totalPrice; if (sourceCodeApplyEditModel != null) { model.DiscountAmount = sourceCodeApplyEditModel.DiscountApplied; model.SourceCode = sourceCodeApplyEditModel.SourceCode; } if (order != null) { var cancelledOrderDetail = order.OrderDetails.Where(od => od.DetailType == OrderItemType.CancellationFee).Select(od => od).LastOrDefault(); if (cancelledOrderDetail != null) { var paymentsApplied = order.PaymentsApplied.Where(pa => pa.DataRecorderMetaData.DateCreated > cancelledOrderDetail.DataRecorderMetaData.DateCreated.AddMinutes(5)).Select(pd => pd); model.AmountPaid = paymentsApplied.Sum(pa => pa.Amount); } else { model.AmountPaid = order.TotalAmountPaid; } } model.ShippingOptionId = shippingOptionId; return(model); }
public OnlineSchedulingProcessAndCartViewModel Create(TempCart tempCart, Customer customer, EventSchedulingSlot appointmentSlot, string sponsoredBy, string checkoutPhoneNumber) { var model = new OnlineSchedulingProcessAndCartViewModel { CartGuid = tempCart.Guid, PackageId = tempCart.EventPackageId, AppointmentId = tempCart.AppointmentId, CustomerId = tempCart.CustomerId, CustomerName = customer != null ? customer.NameAsString : "", SponsoredBy = sponsoredBy, ProspectCustomerId = tempCart.ProspectCustomerId, EventId = tempCart.EventId, Tests = tempCart.TestId, Products = tempCart.ProductId, IsExistingCustomer = tempCart.IsExistingCustomer, AppointmentTime = appointmentSlot != null ? (DateTime?)appointmentSlot.StartTime : null, IsUsedAppointmentSlotExpiryExtension = tempCart.IsUsedAppointmentSlotExpiryExtension, ScreenResolution = tempCart.ScreenResolution, CheckoutPhoneNumber = checkoutPhoneNumber }; return(model); }