예제 #1
0
 public int BorrowBook(int idPerson, int idBook, int idLib)
 {
     try
     {
         Object[] param = { idBook };
         if (data.Borrows.Find(param).IDReader == idPerson)
         {
             data.Borrows.Remove(data.Borrows.Find(param));
             data.SaveChanges();
             return(1);
         }
     }catch (Exception ee)
     {
         if (checkBook(idBook))
         {
             Borrow br = new Borrow();
             br.IDBook      = idBook;
             br.IDLibrarian = idLib;
             br.IDReader    = idPerson;
             br.Date        = DateTime.Now;
             br.ExpertDate  = DateTime.Now.AddMonths(5);
             data.Borrows.Add(br);
             data.SaveChanges();
             return(0);
         }
         throw ee;
     }
     return(-1);
 }
예제 #2
0
        public void delete(Header l)
        {
            Header li = data.Headers.Find(l.ID);

            data.Headers.Remove(li);
            data.SaveChanges();
        }
예제 #3
0
 public void AddReader(Reader re)
 {
     data.Readers.Add(re);
     data.SaveChanges();
 }