public ActionResult GetDownload(Guid id, bool agree = false, string fileVersion = "") { if (id == Guid.Empty) { return(HttpNotFound()); } var orderItem = _orderService.GetOrderItemByGuid(id); if (orderItem == null) { return(HttpNotFound()); } var order = orderItem.Order; var product = orderItem.Product; var hasNotification = false; if (!_downloadService.IsDownloadAllowed(orderItem)) { hasNotification = true; NotifyError(T("Common.Download.NotAllowed")); } if (_customerSettings.DownloadableProductsValidateUser) { if (_workContext.CurrentCustomer == null) { return(new HttpUnauthorizedResult()); } if (order.CustomerId != _workContext.CurrentCustomer.Id) { hasNotification = true; NotifyError(T("Account.CustomerOrders.NotYourOrder")); } } Download download; if (fileVersion.HasValue()) { download = _downloadService.GetDownloadByVersion(product.Id, "Product", fileVersion); } else { download = _downloadService.GetDownloadsFor(product).FirstOrDefault(); } if (download == null) { hasNotification = true; NotifyError(T("Common.Download.NoDataAvailable")); } if (product.HasUserAgreement && !agree) { hasNotification = true; } if (!product.UnlimitedDownloads && orderItem.DownloadCount >= product.MaxNumberOfDownloads) { hasNotification = true; NotifyError(T("Common.Download.MaxNumberReached", product.MaxNumberOfDownloads)); } if (hasNotification) { return(RedirectToAction("UserAgreement", "Customer", new { id, fileVersion })); } if (download.UseDownloadUrl) { orderItem.DownloadCount++; _orderService.UpdateOrder(order); return(new RedirectResult(download.DownloadUrl)); } else { var data = _downloadService.LoadDownloadBinary(download); if (data == null || data.LongLength == 0) { NotifyError(T("Common.Download.NoDataAvailable")); return(RedirectToAction("UserAgreement", "Customer", new { id = id })); } orderItem.DownloadCount++; _orderService.UpdateOrder(order); return(GetFileContentResultFor(download, product, data)); } }