protected void Session_Start() { BaseUser.IdMax = 0; // Init Authors GenerateAuthors(); var dal = new AuthorDAL((List <Author>)Session["Authors"]); dal.Delete(2); dal.Update(3, new Author() { Id = 3, Firstname = "FirstName", Name = "Name" }); GenerateBooks(); GenerateMembers(); Session["BooksBorrowing"] = new List <BooksBorrowing>(); // Create test BooksBorrowing List <Author> authors = (List <Author>)Session["Authors"]; List <Member> members = (List <Member>)Session["Members"]; List <Book> books = (List <Book>)Session["Books"]; var dalResa = new ReservationDAL((List <BooksBorrowing>)Session["BooksBorrowing"]); // Books classic BooksBorrowing resa = new BooksBorrowing(); resa.beginDate = new DateTime(); resa.isReturned = false; resa.book = books.ElementAt(0); resa.user = members.ElementAt(0); resa.returnDate = new DateTime(2017, 08, 31); dalResa.Add(resa); // Return date resa = new BooksBorrowing(); resa.beginDate = new DateTime(2017, 07, 01); resa.isReturned = false; resa.book = books.ElementAt(1); resa.user = members.ElementAt(1); resa.returnDate = new DateTime(2017, 07, 15); resa.daysRetard = (int)(DateTime.Now - (DateTime)resa.returnDate).TotalDays; dalResa.Add(resa); // Is returned resa = new BooksBorrowing(); resa.beginDate = new DateTime(2017, 07, 15); resa.book = books.ElementAt(2); resa.user = members.ElementAt(2); resa.isReturned = true; resa.returnDate = new DateTime(2017, 07, 17); dalResa.Add(resa); }
public ActionResult Return(int Id) // Marquer une réservation comme retournée { // Récupération des réservations en cours ReservationDAL dal = new ReservationDAL((List <BooksBorrowing>)Session["BooksBorrowing"]); BooksBorrowing resa = dal.Read(Id); // Marqué la reservation comme retournée et la mettre à jour resa.isReturned = true; dal.Update(resa.Id, resa); return(RedirectToAction("Index")); }