Exemple #1
0
        public void ChangeStatus(Book book)
        {
            if (book.Status == Status.Available)
            {
                var user = FindUserById(book.UserId);
                user.NumberOfBooks--;
                book.EndBookingDate = null;
                book.ReturnDate     = null;
                book.BookingDate    = null;
                book.BorrowingDate  = null;
                book.UserId         = null;
            }

            if (book.Status == Status.Booked)
            {
                var user = FindUserById(book.UserId);
                book.BookingDate    = DateTime.Now.Date;
                book.EndBookingDate = book.BookingDate.Value.AddDays(3);
                book.BorrowingDate  = null;
                book.ReturnDate     = null;
            }

            if (book.Status == Status.Borrowed)
            {
                book.BookingDate    = null;
                book.EndBookingDate = null;
                book.BorrowingDate  = DateTime.Now.Date;
                book.ReturnDate     = book.BorrowingDate.Value.AddDays(180);
            }

            LibraryDb.Entry(book).State = System.Data.Entity.EntityState.Modified;
        }
Exemple #2
0
 public virtual void Delete(TEntity entityToDelete)
 {
     if (context.Entry(entityToDelete).State == EntityState.Detached)
     {
         dbSet.Attach(entityToDelete);
     }
     dbSet.Remove(entityToDelete);
 }
Exemple #3
0
 public void Actualize(Category category)
 {
     _db.Entry(category).State = EntityState.Modified;
 }
Exemple #4
0
 public void Actualize(Book book)
 {
     _db.Entry(book).State = EntityState.Modified;
 }
Exemple #5
0
 public void Actualize(Order order)
 {
     _db.Entry(order).State = EntityState.Modified;
 }