public ActionResult Export(IEnumerable <OrderModel> orders) { var ordersWithShipping = orders .Where(x => x.Selected) .Select(x => { var order = _service.GetOrderForCsv(x.OrderId.ToString()); order.Weight = x.Weight; order.ServiceCode = x.ShippingMethod.Replace("string:", ""); order.PackageSize = x.PackageSize.Replace("string:", ""); return(order); }) .OrderBy(x => x.ServiceCode) .ThenBy(x => x.Weight) .ThenBy(x => x.Name); var bytes = WriteCsvToMemory(ordersWithShipping); return(File(bytes, "text/csv", DateTime.UtcNow.ToString("yyyy-MM-dd") + " Bricklink Export.csv")); }
public ActionResult GetOrderInfo(string orderId) { var order = _service.GetOrderForCsv(orderId); return(Json(order, JsonRequestBehavior.AllowGet)); }