Ejemplo n.º 1
0
        public void UserDelete(int id)
        {
            BibliotekaEntities db = new BibliotekaEntities();

            var query = (from x in db.User where x.UserId == id select x).SingleOrDefault();
            query.IsActive = false;
            db.SaveChanges();
        }
Ejemplo n.º 2
0
        public void Destroy(BorrowDTO dBorrow)
        {
            BibliotekaEntities db = new BibliotekaEntities();

            var query = (from x in db.Borrow where x.BorrowId == dBorrow.BorrowId select x).SingleOrDefault();

            //db.Borrow.Remove(query);
            query.IsReturned = true;
            db.SaveChanges();
        }
Ejemplo n.º 3
0
        public void Create(BookCreateDTO newBook)
        {
            BibliotekaEntities db = new BibliotekaEntities();

            db.Book.Add(
            new Book
            {
                Title = newBook.Title,
                ReleaseDate = newBook.ReleaseDate,
                ISBN = newBook.ISBN,
                Count = newBook.Count,
                Author = newBook.Author,
                AddDate = DateTime.Now,
                DictBookGenre = (from x in db.DictBookGenre where x.Name == newBook.DictBookGenre select x).SingleOrDefault()
            });
            db.SaveChanges();
        }
Ejemplo n.º 4
0
        public void Create(BorrowCreateDTO newBorrow)
        {
            BibliotekaEntities db = new BibliotekaEntities();

            foreach (var borrow in newBorrow.ChosenBooks)
            {
                db.Borrow.Add(
                new Borrow
                {
                    FromDate = DateTime.Now,
                    ToDate = newBorrow.ToDate,
                    User = (from x in db.User where x.UserId == newBorrow.Users select x).SingleOrDefault(),
                    Book = (from x in db.Book where x.BookId == borrow select x).SingleOrDefault()
                });
                db.SaveChanges();
            }
        }
Ejemplo n.º 5
0
        public void UserCreate(UserCreateDTO nUser)
        {
            BibliotekaEntities db = new BibliotekaEntities();

            db.User.Add(
            new User
            {
                FirstName = nUser.FirstName,
                LastName = nUser.LastName,
                Email = nUser.Email,
                Phone = nUser.Phone,
                BirthDate = nUser.BirthDate,
                IsActive = nUser.IsActive,
                AddDate = DateTime.Now
            });

            db.SaveChanges();
        }
Ejemplo n.º 6
0
        public void UserEdit(UserEditDTO eUser, int id)
        {
            BibliotekaEntities db = new BibliotekaEntities();

            var query = (from x in db.User where x.UserId == id select x).SingleOrDefault();

            query.FirstName = eUser.FirstName;
            query.LastName = eUser.LastName;
            query.Email = eUser.Email;
            query.Phone = eUser.Phone;
            query.ModifiedDate = DateTime.Now;
            query.IsActive = eUser.IsActive;
            db.SaveChanges();
        }
Ejemplo n.º 7
0
        public void Edit(BookEditDTO eBook, int id)
        {
            BibliotekaEntities db = new BibliotekaEntities();

            var query = (from x in db.Book where x.BookId == id select x).SingleOrDefault();

            query.Author = eBook.Author;
            query.Count = eBook.Count;
            query.DictBookGenre = (from x in db.DictBookGenre where x.Name == eBook.DictBookGenre select x).SingleOrDefault();
            query.ISBN = eBook.ISBN;
            query.ModifiedDate = DateTime.Now;
            query.ReleaseDate = eBook.ReleaseDate;
            query.Title = eBook.Title;
            db.SaveChanges();
        }
Ejemplo n.º 8
0
        public void DestroyV2(UserDTO model)
        {
            BibliotekaEntities db = new BibliotekaEntities();

            foreach (var x in model.books)
            {
                var query = (from y in db.Borrow where y.BorrowId == x select y).SingleOrDefault();
                //db.Borrow.Where(y => y.BorrowId == x).SingleOrDefault().
                query.IsReturned = true;

            }
            db.SaveChanges();
            //db.Borrow.Remove(query);
        }