Ejemplo n.º 1
0
        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 Delete(int id) // Suppression d'un auteur
        {
            AuthorDAL authorDAL = new AuthorDAL((List <Author>)Session["Authors"]);

            Author author = authorDAL.Read(id); // R2cupération des infos d'un livre pour un id donné

            authorDAL.Delete(id);

            AuthorModelView model = new AuthorModelView((List <Author>)Session["Authors"]);

            return(View(model));
        }
Ejemplo n.º 3
0
        //------------------------------------------------------------------------------------------------------

        public ActionResult Delete(int?id)
        {
            if (id != null)
            {
                using (AuthorDAL service = new AuthorDAL())
                    try
                    {
                        service.Delete(id.Value);
                        TempData["Message"] = Helper.MsgBox.GetMsg("success", "Success! ", "Your data has been removed");
                    }
                    catch (Exception ex)
                    {
                        TempData["Message"] = Helper.MsgBox.GetMsg("danger", "Error", ex.Message);
                    }
            }
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 4
0
 public bool Delete(int authorID)
 {
     return(_authorDAL.Delete(authorID) > 0);
 }