예제 #1
0
        //ADD PRODUCT TO CUSTOMER ACCOUNT I.E RENTED PRODUCT
        public ActionResult RentProduct(ProductModel product)
        {
            //CREATE INSTANCE OF RENT PRODUCT MODEL CLASS
            RentProductModel rProduct = new RentProductModel()
            {
                ProductId    = product.PId,
                VendorId     = product.VendorId,
                StartDate    = product.PStartDate,
                EndDate      = product.PEndDate,
                CategoryId   = product.CategoryId,
                ProductImage = product.PImage1,
                ProductName  = product.PName
            };

            rProduct.PayStatus     = true;
            rProduct.PayableAmount = product.PUnitCost * (product.PEndDate - product.PStartDate).TotalDays;
            rProduct.BookingStatus = false;
            UserLoginModel user = (UserLoginModel)HttpContext.Session["USER"];

            rProduct.UserId = user.Id;

            bool status = productActionContext.RentNewProduct(rProduct);

            if (!status)
            {
                TempData["FailStatus"] = true;
                return(RedirectToAction("ProductDetails", "Product", new { id = product.PId }));
            }
            TempData["FailStatus"] = false;
            return(RedirectToAction("MyOrders", "User"));
        }