Ejemplo n.º 1
0
        public ActionResult EditBook(int id)
        {
            BookTypeRepository bookTypeRepository = new BookTypeRepository();
            BookTypes          bookType           = bookTypeRepository.GetSingleBookType(id);

            return(View("EditBook", bookType));
        }
Ejemplo n.º 2
0
        public static void EnterFiles()
        {
            string           path    = "books.csv";
            List <BookTypes> books   = new List <BookTypes>();
            StreamReader     file    = new StreamReader(path);
            string           curLine = file.ReadLine();

            while ((curLine = file.ReadLine()) != null)
            {
                books.Add(GetBook(curLine.Split(',')));
            }

            foreach (BookTypes book in books)
            {
                BookRepository     bookRepository     = new BookRepository();
                BookTypeRepository bookTypeRepository = new BookTypeRepository();
                if (CheckBookTitleIsFree(book.title))
                {
                    bookTypeRepository.InsertBookType(book);
                }
                Book copy = new Book()
                {
                    BookTypes_id = bookTypeRepository.GetSingleBookType(book.title).id
                };
                for (int i = 0; i < book.availableCopies; i++)
                {
                    bookRepository.InsertBook(copy);
                }
            }
        }
Ejemplo n.º 3
0
        public ActionResult ViewStatus(int id)
        {
            BookTypeRepository bookTypeRepository = new BookTypeRepository();
            BookTypes          bookTypes          = bookTypeRepository.GetSingleBookType(id);

            return(View(bookTypes));
        }
Ejemplo n.º 4
0
        public HttpResponseMessage DeleteBookType(int id)
        {
            BookTypeRepository ctxBookType = new BookTypeRepository();

            ctxBookType.DeleteBookType(id);
            HttpResponseMessage ms = Request.CreateResponse(HttpStatusCode.Accepted);

            return(ms);
        }
Ejemplo n.º 5
0
        public ActionResult EditBookResult(BookTypes bookType)
        {
            AuthorRepository   authorRepository   = new AuthorRepository();
            BookTypeRepository bookTypeRepository = new BookTypeRepository();

            bookType.author_id = authorRepository.GetAuthorId(bookType.author.name);
            bookTypeRepository.UpdateBookType(bookType);
            return(View("Library", new LibraryParameters()));
        }
Ejemplo n.º 6
0
        public HttpResponseMessage UpdateBookType([FromBody] BookType _BookType)
        {
            BookTypeRepository ctxBookType = new BookTypeRepository();

            ctxBookType.UpdateBookType(_BookType);
            HttpResponseMessage ms = Request.CreateResponse(HttpStatusCode.OK);

            ms.Headers.Location = new Uri(Request.RequestUri + "/" + (_BookType.BookTypeID).ToString());
            return(ms);
        }
Ejemplo n.º 7
0
        public ActionResult TakeOutBook(int id)
        {
            UserRepository     userRepository     = new UserRepository();
            BookTypeRepository bookTypeRepository = new BookTypeRepository();
            BookRental         bookRental         = new BookRental()
            {
                User     = userRepository.GetSingleUser(Session["userName"].ToString()),
                BookType = bookTypeRepository.GetSingleBookType(id)
            };

            return(View(bookRental));
        }
Ejemplo n.º 8
0
        public HttpResponseMessage GetAllBookTypes()
        {
            BookTypeRepository     ctxBookType = new BookTypeRepository();
            IEnumerable <BookType> lsBookTypes;

            lsBookTypes = ctxBookType.GetBookType();
            if (lsBookTypes.Count() > 0)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, lsBookTypes));
            }
            {
                return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Item not found"));
            }
        }
Ejemplo n.º 9
0
        public HttpResponseMessage GetBookTypeByID(int id)
        {
            BookTypeRepository ctxBookType = new BookTypeRepository();

            BookType _BookType = ctxBookType.GetBookType().FirstOrDefault(x => x.BookTypeID == id);

            if (_BookType != null)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, _BookType));
            }
            {
                return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Item not found"));
            }
        }
Ejemplo n.º 10
0
        public static Boolean CheckBookTitleIsFree(string title)
        {
            BookTypeRepository bookTypeRepository = new BookTypeRepository();

            List <BookTypes> bookTypes = bookTypeRepository.GetBookTypes();

            foreach (BookTypes bookType in bookTypes)
            {
                if (bookType.title == title)
                {
                    return(false);
                }
            }
            return(true);
        }
Ejemplo n.º 11
0
        public BookTagView(BookTag bookTag)
        {
            SimpleValue simpleValue;
            BookTypeRepository bookTypeRepository;
            BookType bookType;

            bookTypeRepository = new BookTypeRepository();
            this.Id = bookTag.Id;
            this.HumanName = bookTag.Name;
            bookType = (BookType)bookTypeRepository.FindById(bookTag.BookTypeId);
            this.BookType = bookType.Name;

            simpleValue = BookTagService.FindById(this.Id);
            this.MashineName = simpleValue.MachineName;
        }
Ejemplo n.º 12
0
        public static BookTypes CreateBookType(BookData book)
        {
            AuthorRepository   authorRepository   = new AuthorRepository();
            BookTypeRepository bookTypeRepository = new BookTypeRepository();
            BookTypes          bookType           = new BookTypes()
            {
                author_id     = authorRepository.GetAuthorId(book.author),
                title         = book.title,
                coverImageURL = book.coverImageURL,
                genre         = book.genre,
                ISBN          = book.ISBN,
                releaseDate   = book.releaseDate
            };

            bookTypeRepository.InsertBookType(bookType);
            return(bookTypeRepository.GetSingleBookType(bookType.title));
        }
Ejemplo n.º 13
0
        public UnitOfWork(PlutoContext context)
        {
            _ILog = Log.GetInstance;

            _context                  = context;
            AppUsers                  = new UserRepository(context);
            Students                  = new StudentRepository(context);
            PaymentHistories          = new PaymentHistoryRepository(context);
            Payments                  = new PaymentRepository(context);
            studentclasses            = new StudentClassRepository(context);
            departments               = new DepartmentRepository(context);
            regions                   = new RegionRepository(context);
            studentstatuses           = new StudentStatusRepository(context);
            employees                 = new EmployeeRepository(context);
            employeedocuments         = new EmployeeDocumentRepository(context);
            payrollamounts            = new PayrollAmountRepository(context);
            employeecategories        = new EmployeeCategoryRepository(context);
            employeelevelsofeducation = new EmployeeLevelOfEducationRepository(context);
            payrollrates              = new PayrollRateRepository(context);
            taxrates                  = new TaxRateRepository(context);
            ssnitrates                = new SSNITRateRepository(context);
            studentsubjects           = new StudentSubjectRepository(context);
            payrollallowances         = new PayrollAllowancesRepository(context);
            employeetypes             = new EmployeeTypeRepository(context);
            employeeloanhistories     = new EmployeeLoanHistoryRepository(context);
            employeeloans             = new EmployeeLoanRepository(context);
            exams          = new ExamRepository(context);
            marks          = new MarkRepository(context);
            externalhelper = new ExternalHelperRepository(context);

            hostels           = new HostelRepository(context);
            libraries         = new LibraryRepository(context);
            transports        = new TransportRepository(context);
            expenses          = new ExpenseRepository(context);
            expensecategories = new ExpenseCategoryRepository(context);
            incomes           = new IncomeRepository(context);
            incomecategories  = new IncomeCategoryRepository(context);
            books             = new BookRepository(context);
            booktypes         = new BookTypeRepository(context);
            rooms             = new RoomRepository(context);
            payrolldates      = new PayrollDateRepository(context);
            allowances        = new AllowanceRepository(context);
        }
Ejemplo n.º 14
0
        public static bool CheckNewBookTitle(string title)
        {
            BookTypeRepository bookTypeRepository = new BookTypeRepository();

            return(bookTypeRepository.GetSingleBookType(title) == null);
        }