private string GetAmazonOrderId(Order order) { var amazonOrder = _session.QueryOver <AmazonOrder>().Where(item => item.Order.Id == order.Id).SingleOrDefault(); return(amazonOrder == null ? string.Empty : amazonOrder.AmazonOrderId); }
public ActionResult WriteDownloadToResponse(HttpResponseBase response, Order order, OrderLine orderLine) { if (order == null || orderLine == null) return new ContentResult { Content = "Error", ContentType = "text/plain" }; var errors = _rules.SelectMany(rule => rule.GetErrors(order, orderLine)); if (errors.Any()) return new ContentResult { Content = "Sorry the file you requested to be downloaded is unavailable. Either the order is not paid or the file has been downloaded a maximum amount of times. Contact the store owner if you believe this to be incorrect.", ContentType = "text/plain" }; if (!_fileSystem.Exists(orderLine.DownloadFileUrl)) return new ContentResult { Content = "File no longer exists.", ContentType = "text/plain" }; EcommerceDownloadResult writeDownloadToResponse; try { writeDownloadToResponse = new EcommerceDownloadResult(_fileSystem, orderLine); } catch (Exception exception) { _logService.Insert(new Log { Error = new Error(exception), Message = "Error downloading file" }); return new ContentResult { Content = "An error occoured, please contact the store owner.", ContentType = "text/plain" }; } orderLine.NumberOfDownloads++; _session.Transact(session => session.Update(orderLine)); return writeDownloadToResponse; }
public IList<OrderRewardPointsHistory> GetOrderRewardPointsUsage(Order order) { return _session.QueryOver<OrderRewardPointsHistory>() .Where(history => history.Order.Id == order.Id) .OrderBy(history => history.CreatedOn).Asc .Cacheable().List(); }
public string GetAnalayticsCode(Order order, string trackingScript) { if (order == null) return trackingScript; if (!string.IsNullOrWhiteSpace(trackingScript)) { var trackingScriptContainsEcommerce = trackingScript.Contains("{ecommerce}"); if (!trackingScriptContainsEcommerce) return trackingScript; var trackingCodeSb = new StringBuilder(); var shippingCity = order.ShippingAddress != null ? order.ShippingAddress.City : ""; var shippingCounty = order.ShippingAddress != null ? order.ShippingAddress.StateProvince : ""; var shippingCountry = order.ShippingAddress != null ? order.ShippingAddress.GetCountryName() : ""; trackingCodeSb.Append(string.Format(AddTrans, order.Id, order.Site.Name, order.Total, order.Tax, order.ShippingTotal, shippingCity, shippingCounty, shippingCountry)); foreach (var orderLine in order.OrderLines) { trackingCodeSb.Append(string.Format(AddItem, order.Id, orderLine.SKU, orderLine.Name, orderLine.Options, orderLine.UnitPrice, orderLine.Quantity)); } trackingCodeSb.Append(TrackTrans); return trackingScript.Replace("//{ecommerce}", trackingCodeSb.ToString()); } return string.Empty; }
private void SetDocument(ref Document document, Order order) { var tableColor = new Color(0, 0, 0, 0); Section section = document.AddSection(); //HEADER SetHeader(ref section); //FOOTER SetFooter(ref section); //INFO SetInfo(order, ref section); //TABLE STYLE Table table = SetTableStyle(ref section, tableColor); //HEADERS SetTableHeader(ref table, tableColor); //ITEMS SetTableData(order, ref table); //SUMMARY SetTableSummary(order, ref table); }
public void MarkAsShipped(Order order) { order.ShippingDate = CurrentRequestData.Now; order.ShippingStatus = ShippingStatus.Shipped; _session.Transact(session => session.Update(order)); EventContext.Instance.Publish<IOnOrderShipped, OrderShippedArgs>(new OrderShippedArgs { Order = order }); }
public void OrderController_Edit_ReturnsAViewResult() { var order = new Order(); var result = _orderController.Edit(order); result.Should().BeOfType<ViewResult>(); }
public void OrderController_Edit_ReturnsThePassedObjectAsTheModel() { var order = new Order(); var result = _orderController.Edit(order); result.As<ViewResult>().Model.Should().Be(order); }
public void MarkAsPaid(Order order) { order.PaidDate = CurrentRequestData.Now; order.PaymentStatus = PaymentStatus.Paid; _session.Transact(session => session.Update(order)); EventContext.Instance.Publish<IOnOrderPaid, OrderPaidArgs>(new OrderPaidArgs { Order = order }); }
public void SetTaxesService_SetTax_ShouldCallSetShippingTaxes() { var order = new Order() { Total = 10 }; _setTaxes.SetTax(ref order,0); A.CallTo(() => _setTaxDetails.SetShippingTaxes(ref order)).MustHaveHappened(); }
public void SetTaxesService_SetTax_ShouldSetTaxIfTaxValueIsProvided() { var order = new Order() { Total = 10 }; _setTaxes.SetTax(ref order, 5); order.Tax.Should().Be(5); }
public void SetTaxDetails_SetOrderLinesTaxes_ShouldCallGetDefaultRate() { var orderLine = new OrderLine() {UnitPrice = 1, Price = 2, Quantity = 2}; var order = new Order() { Total = 10, ShippingTotal = 1, OrderLines = new List<OrderLine>(){orderLine}}; _setTaxes.SetOrderLinesTaxes(ref order); A.CallTo(() => _taxRateManager.GetRateForOrderLine(orderLine)).MustHaveHappened(); }
public void ACallToWriteDownloadToResponseShouldHappen() { var order = new Order(); var orderLine = new OrderLine(); _downloadOrderedFileController.Download(order, orderLine); A.CallTo(() => _downloadProductService.WriteDownloadToResponse(_downloadOrderedFileController.Response, order, orderLine)).MustHaveHappened(); }
public void IfNoGiftCardsAppliedNoUsagesShouldBeCreated() { var order = new Order(); GiftCardApplier giftCardApplier = new GiftCardApplierBuilder().Build(); order = giftCardApplier.Apply(new List<GiftCard>(), order); order.GiftCardUsages.Should().BeEmpty(); }
public void SetTaxesService_SetTax_ShouldNotProceedWithSettingTaxIfTaxValueIsProvided() { var order = new Order() { Total = 10 }; _setTaxes.SetTax(ref order, 5); A.CallTo(() => _setTaxDetails.SetOrderLinesTaxes(ref order)).MustNotHaveHappened(); A.CallTo(() => _setTaxDetails.SetShippingTaxes(ref order)).MustNotHaveHappened(); }
public byte[] GeneratePDF(Order order) { Document pdf = SetDocumentInfo(order); SetDocumentStyles(ref pdf); SetDocument(ref pdf, order); return GetDocumentToByteArray(ref pdf); }
public void IfAllChecksPassReturnAnEcommerceResult() { var order = new Order(); var orderLine = new OrderLineBuilder().WithFileUrl("test-file-url").Build(); HttpResponseBase response = new OutOfContextResponseBuilder().Build(); A.CallTo(() => _fileSystem.Exists("test-file-url")).Returns(true); var writeDownloadToResponse = _downloadProductService.WriteDownloadToResponse(response, order, orderLine); writeDownloadToResponse.Should().BeOfType<EcommerceDownloadResult>(); }
public void AddOrderNoteAudit(string note, Order order) { var orderNote = new OrderNote { Note = note, ShowToClient = false, Order = order }; order.OrderNotes.Add(orderNote); _session.Transact(session => session.SaveOrUpdate(orderNote)); }
public void IfFileDoesNotExistStreamShouldNotBeWrittenTo() { var order = new Order(); var orderLine = new OrderLineBuilder().WithFileUrl("test-file-url").Build(); HttpResponseBase response = new OutOfContextResponseBuilder().Build(); A.CallTo(() => _fileSystem.Exists("test-file-url")).Returns(false); _downloadProductService.WriteDownloadToResponse(response, order, orderLine); A.CallTo(() => _fileSystem.WriteToStream(A<string>._, A<Stream>._)).MustNotHaveHappened(); }
public void IfAnyRuleErrorsStreamShouldNotBeWrittenTo() { var order = new Order(); var orderLine = new OrderLineBuilder().Build(); HttpResponseBase response = new OutOfContextResponseBuilder().Build(); SetRulesStatus(order, orderLine, false); _downloadProductService.WriteDownloadToResponse(response, order, orderLine); A.CallTo(() => _fileSystem.WriteToStream(A<string>._, A<Stream>._)).MustNotHaveHappened(); }
public void OrderAdminService_Cancel_ShouldCallOrderCancelled() { var order = new Order {IsCancelled = true}; Session.Transact(session => session.Save(order)); _orderAdminService.Cancel(order); A.CallTo( () => EventContext.FakeEventContext.Publish<IOnOrderCancelled, OrderCancelledArgs>( A<OrderCancelledArgs>.That.Matches(args => args.Order == order))).MustHaveHappened(); }
public void IfTheCardValueIsGreaterThanTheTotalOnlyTheTotalAmountShouldBeApplied() { var order = new Order {Total = 50}; var giftCard1 = new GiftCard {Value = 100}; var giftCards = new List<GiftCard> {giftCard1}; GiftCardApplier giftCardApplier = new GiftCardApplierBuilder().Build(); order = giftCardApplier.Apply(giftCards, order); order.GiftCardUsages.Should().HaveCount(1); order.GiftCardUsages[0].Amount.Should().Be(50); }
public void OrderAdminService_MarkAsShipped_ShouldCallOrderShipped() { var order = new Order {ShippingStatus = ShippingStatus.Shipped, ShippingDate = DateTime.UtcNow}; Session.Transact(session => session.Save(order)); _orderAdminService.MarkAsShipped(order); A.CallTo( () => EventContext.FakeEventContext.Publish<IOnOrderShipped, OrderShippedArgs>( A<OrderShippedArgs>.That.Matches(args => args.Order == order))).MustHaveHappened(); }
public void OrderRefundService_Add_ShouldCallOrderFullyRefunded() { var order = new Order {Total = 100}; var orderRefund = new OrderRefund {Amount = 100, Order = order}; _orderRefundService.Add(orderRefund); A.CallTo( () => EventContext.FakeEventContext.Publish<IOnOrderFullyRefunded, OrderFullyRefundedArgs>( A<OrderFullyRefundedArgs>.That.Matches(args => args.Order == order))).MustHaveHappened(); }
public async Task<LoginAndAssociateOrderResult> LoginAndAssociateOrder(LoginModel model, Order order) { LoginResult authenticateUser = await _loginService.AuthenticateUser(model); if (!authenticateUser.Success) return new LoginAndAssociateOrderResult { Error = "We were unable to log you in, please check your password and try again" }; order.User = CurrentRequestData.CurrentUser; _session.Transact(session => session.Update(order)); return new LoginAndAssociateOrderResult(); }
private static Document SetDocumentInfo(Order order) { return new Document { Info = { Title = CurrentRequestData.CurrentSite.Name + " Order: " + order.Guid, Subject = CurrentRequestData.CurrentSite.Name + " Order: " + order.Guid, Keywords = "MrCMS, Order", Author = CurrentRequestData.CurrentUser.Name } }; }
public async Task<RegisterAndAssociateOrderResult> RegisterAndAssociateOrder(RegisterModel model, Order order) { if (!_registrationService.CheckEmailIsNotRegistered(model.Email)) return new RegisterAndAssociateOrderResult { Error = "The provided email already has an account associated" }; User registeredUser = await _registrationService.RegisterUser(model); order.User = registeredUser; _session.Transact(session => session.Update(order)); return new RegisterAndAssociateOrderResult(); }
public void SetTax(ref Order order, decimal tax) { if (tax > 0) { order.Tax = tax; return; } if (!_amazonSyncSettings.TryCalculateVat || !_taxSettings.TaxesEnabled) return; _setTaxDetails.SetOrderLinesTaxes(ref order); _setTaxDetails.SetShippingTaxes(ref order); }
public void ReturnsTheResultOfServiceCall() { var order = new Order(); var orderLine = new OrderLine(); var stubFileStreamResult = new StubFileStreamResult(); A.CallTo( () => _downloadProductService.WriteDownloadToResponse(_downloadOrderedFileController.Response, order, orderLine)).Returns(stubFileStreamResult); var actionResult = _downloadOrderedFileController.Download(order, orderLine); actionResult.Should().Be(stubFileStreamResult); }
public void IfAGiftCardWithLessValueThanTheTotalIsAddedItShouldBeUsedInFull() { var order = new Order {Total = 50}; var giftCard = new GiftCard {Value = 25}; var giftCards = new List<GiftCard> {giftCard}; GiftCardApplier giftCardApplier = new GiftCardApplierBuilder().Build(); order = giftCardApplier.Apply(giftCards, order); order.GiftCardUsages.Should().HaveCount(1); order.GiftCardUsages[0].Amount.Should().Be(25); giftCard.GiftCardUsages.Should().HaveCount(1); giftCard.GiftCardUsages[0].Should().Be(order.GiftCardUsages[0]); }
public void UpdateOrder(Order order) { order.AuthorisationToken = Details.Token; var paymentInfo = Details.PaymentInfo.FirstOrDefault(); if (paymentInfo != null) { order.PaymentStatus = paymentInfo.PaymentStatus.GetPaymentStatus(); if (order.PaymentStatus.Equals(PaymentStatus.Paid)) { order.ShippingStatus = ShippingStatus.Unshipped; order.PaidDate = CurrentRequestData.Now; } order.CaptureTransactionId = paymentInfo.TransactionID; } }