Esempio n. 1
0
        public async Task <ActionResult <BorrowFormModel> > Fetch(int borrowId)
        {
            var entity = Borrows.GetBorrow(borrowId);

            if (entity == null)
            {
                return(NotFound());
            }

            return(Mapper.Map <BorrowFormModel>(entity));
        }
Esempio n. 2
0
        public async Task <ActionResult> ReturnBook(int borrowId)
        {
            if (!Roles.IsLibrarian(User.Identity.Name) && !Roles.IsAdmin(User.Identity.Name))
            {
                return(Forbid());
            }

            var entity = Borrows.GetBorrow(borrowId);

            if (entity == null)
            {
                return(NotFound());
            }

            entity.Status          = BorrowStatus.Inactive;
            entity.ReturnLibrarian = Users.GetUser(User.Identity.Name);
            entity.ReturnTime      = DateTime.UtcNow;

            Borrows.Update(entity);

            return(Accepted());
        }