private static InvoiceRow GetInvoiceRow(CartRowDto cartRow, Invoice invoice)
        {
            var invoiceRow = new InvoiceRow();
            invoiceRow.Invoice = invoice;
            invoiceRow.StartDate = DateTime.Now;
            invoiceRow.EndDate = invoiceRow.StartDate.AddDays(cartRow.DaysRented);
            invoiceRow.EquipmentId = cartRow.EquipmentId;

            return invoiceRow;
        }
示例#2
0
        public ActionResult AddToCart(int? equipmentId, int? daysRented)
        {
            if (!equipmentId.HasValue || equipmentId == 0
                || !daysRented.HasValue || daysRented == 0)
                return Json(false, JsonRequestBehavior.AllowGet);

            var cart = GetOrInitCartFromSession();

            var inventoryList = GetAndCacheInventoryList();
            var equipmentName = inventoryList.Single(eq => eq.Id == equipmentId.Value).Name;

            var cartRow = new CartRowDto
            {
                EquipmentId = equipmentId.Value,
                EquipmentName = equipmentName,
                DaysRented = daysRented.Value
            };
            cart.Rows.Add(cartRow);

            return Json(cart.Rows.Count, JsonRequestBehavior.AllowGet);
        }