public ActionResult RentDetails(int idr) { RentDb dbRent = new RentDb(); ModelState.Clear(); return(View(dbRent.GetRentDetails(idr))); }
public ActionResult Rents() { RentDb dbRent = new RentDb(); ModelState.Clear(); return(View(dbRent.GetRents())); }
/// <summary> /// Display the rents concerning the user connected /// </summary> /// <param name="id"></param> /// <returns>View</returns> public ActionResult Rents(int id) { RentDb dbRent = new RentDb(); ModelState.Clear(); return(View(dbRent.GetDistinctRentByCustomer(id))); }
/// <summary> /// Display a PDF with the information of the customer /// and the products for one rent selected. /// The PDF is open in a new tab from the rents page. /// Rotativa is a package to help displaying PDF. /// </summary> /// <param name="idR"></param> /// <returns></returns> public ActionResult DownloadBill(int idR) { RentDb dbProducts = new RentDb(); ModelState.Clear(); BillViewModel model = dbProducts.GetRentDetails(idR); return(new Rotativa.ViewAsPdf("ViewPDF", model)); }
/// <summary> /// Show in a partial view the result of top n rented products /// In the index page, the user choose top 5, 10, 25 etc /// and then the partial view ask the the ressult to the database /// depending on the user demand /// </summary> /// <param name="topValue"></param> /// <returns>PartialView</returns> public ActionResult IndexTop(int topValue) { ProductsDb dbProducts = new ProductsDb(); RentDb dbRent = new RentDb(); ModelState.Clear(); AccueilViewModel vm = new AccueilViewModel { Product = dbProducts.GetTopNProducts(topValue) }; return(PartialView(vm)); }
public ActionResult ReturnBack(int idCustomer, int idRent) { RentDb dbRent = new RentDb(); bool rentValid; rentValid = dbRent.UpdateRentReturnedBack(idRent); if (rentValid) { return(RedirectToAction("Rents")); } else { return(RedirectToAction("RentDetails", new { idc = idCustomer, idr = idRent })); } }
public ActionResult Basket(FormCollection collection) { RentDb dbRent = new RentDb(); ProductsDb dbProduct = new ProductsDb(); bool rent = false; bool isRemove = false; bool resultat = false; var claimIdentity = User.Identity as ClaimsIdentity; int idUser = Convert.ToInt32(claimIdentity.FindFirst(ClaimTypes.NameIdentifier).Value); var productList = claimIdentity.FindAll(ClaimTypes.UserData); if (collection["getRentDate"] != null) { foreach (var product in productList) { if (product.Value != "") { // Down the product's stock in DB isRemove = dbProduct.RemoveStock(Convert.ToInt32(product.Value)); resultat = isRemove; if (isRemove == false) { break; } } } } // Create the rent in DB with the date when the customer will get the products in the shop if (resultat) { rent = dbRent.AddRent(Convert.ToDateTime(collection["getRentDate"]), idUser, productList); RemoveAllProductBasket();// Remove all products in basket return(RedirectToAction("Rents", "Rents", new { id = idUser })); } return(RedirectToAction("Basket")); }
/// <summary> /// Show the index page. /// The content depends on whether the user is connected or not /// The page contains the new products and the top n of rented products for anyone /// It shows the products currently rented by someone if he's connected /// </summary> /// <returns>View</returns> public ActionResult Index() { string role = ""; string id = ""; int idUser = 0; if (Request.IsAuthenticated) { var claimIdentity = User.Identity as ClaimsIdentity; if (claimIdentity != null) { role = claimIdentity.FindFirst(ClaimTypes.Role).Value; id = claimIdentity.FindFirst(ClaimTypes.NameIdentifier).Value; idUser = Convert.ToInt32(id); } } ProductsDb dbProducts = new ProductsDb(); RentDb dbRent = new RentDb(); ModelState.Clear(); AccueilViewModel vm = new AccueilViewModel { NewProducts = dbProducts.GetNewProducts() }; if (Request.IsAuthenticated) { if (role == "User") { vm.Rent = dbRent.GetRentByCustomer(idUser); } } return(View(vm)); }