Beispiel #1
0
 public IActionResult Index()
 {
     if (HttpContext.Session.GetString("username") == null)
     {
         return(View("Login"));
     }
     else if (HttpContext.Session.GetInt32("role_id") == 3)
     {
         return(View("Login"));
     }
     else
     {
         var assetModels   = _assets.GetAll();
         var ListingResult = assetModels
                             .Select(result => new AssetIndexListingModel
         {
             Id               = result.Id,
             ImageURL         = result.ImageUrl,
             AuthorOrDirector = _assets.GetAuthorOrDirector(result.Id),
             DeweyCallNumber  = _assets.GetDeweyIndex(result.Id),
             Title            = result.Title,
             Type             = _assets.GetType(result.Id)
         });
         var model = new AssetIndexModel()
         {
             Assets = ListingResult
         };
         return(View(model));
     }
 }
Beispiel #2
0
        //Ação do controller para www.site.com.br/Catalog/Index
        //Deve retornar uma lista inteira do catalogo

        public IActionResult Index()
        {
            //Consulta feita na base
            var assetModels = _assets.GetAll();

            //Filtrar o que será visualizado na View
            var ListingResult = assetModels.Select(result => new AssetIndexListingModel
            {
                //Passar para o construtor os parâmetros que queremos ver na View
                Id               = result.Id,
                ImageUrl         = result.ImageUrl,
                AuthorOrDirector = _assets.GetAuthorOrDirector(result.Id),
                DeweyCallNumber  = _assets.GetDewayIndex(result.Id),
                Title            = result.Title,
                Type             = _assets.GetType(result.Id)
            });;

            //Cria o modelo, baseado nos dados que foram consultados
            var model = new AssetIndexModel()
            {
                Assets = ListingResult
            };

            //retorna o modelo criado para a View Catalog
            return(View(model));
        }
        public IActionResult Index()
        {
            var assetModels   = _assets.GetAll();
            var listingResult = assetModels
                                .Select(result => new AssetIndexListingModel
            {
                Id       = result.Id,
                ImageUrl = result.ImageUrl,
                //for Author OrDiretor we have to implement GetAuthorOrDirector function
                //that we wrote in our service layer , and pass it the result.Id
                AuthorOrDirector = _assets.GetAuthorOrDirector(result.Id),
                //also use a function we wrote befor eto get it
                DeweyCallNumber = _assets.GetDeweyIndex(result.Id),
                Title           = result.Title,
                //use fucntion again:
                Type = _assets.GetType(result.Id)
            });

            var model = new AssetIndexModel()
            {
                Assets = listingResult
            };

            return(View(model));
        }
Beispiel #4
0
        public IActionResult Index()
        {
            // Get all the asset info
            var assetModels = _assets.GetAll();

            // Save the listing results into objects by selecting the data and listing it using our AssetIndexListingModel
            var listingResult = assetModels
                                .Select(result => new AssetIndexListingModel
            {
                Id               = result.Id,
                ImageUrl         = result.ImageUrl,
                Title            = result.Title,
                AuthorOrDirector = _assets.GetAuthorOrDirector(result.Id),
                Type             = _assets.GetType(result.Id),
                DeweyCallNumber  = _assets.GetDeweyIndex(result.Id)
            });

            // Save that into a copy of our container model "AssetIndexModel"
            var model = new AssetIndexModel()
            {
                Assets = listingResult
            };

            // Return the model to the view
            return(View(model));
        }
        public IActionResult Index(string searchString)
        {
            var assetModels = _assets.GetAll();

            if (!String.IsNullOrEmpty(searchString))
            {
                assetModels = assetModels.Where(s => s.Title.Contains(searchString));
            }

            var listingResult = assetModels
                                .Select(result => new AssetIndexListingModel
            {
                Id               = result.Id,
                ImageUrl         = result.ImageUrl,
                AuthorOrDirector = _assets.GetAuthorOrDirector(result.Id),
                DeweyCallNumber  = _assets.GetDeweyIndex(result.Id),
                Title            = result.Title,
                Type             = _assets.GetType(result.Id)
            });

            var model = new AssetIndexModel()
            {
                Assets = listingResult
            };

            return(View(model));
        }
Beispiel #6
0
        public IActionResult Index()
        {
            var assetModels = _assets.GetAll();

            var listingResult = assetModels
                                .Select(result => new AssetIndexListingModel
            {
                Id               = result.Id,
                ImageUrl         = result.ImageUrl,
                AuthorOrDirector = _assets.GetAuthorOrDirector(result.Id),
                DeweyCallNumber  = _assets.GetDeweyIndex(result.Id),
                Title            = result.Title,
                Type             = _assets.GetType(result.Id)
            });

            var model = new AssetIndexModel()
            {
                Assets = listingResult
            };

            return(View(model));


            //return View();
        }
Beispiel #7
0
        public IActionResult Index()
        {
            var assetModels = _asset.GetAll();

            var listingResult = assetModels
                                .Select(a => new AssetIndexListingModel
            {
                Id               = a.Id,
                ImageUrl         = a.ImageUrl,
                AuthorOrDirector = _asset.GetAuthorOrDirector(a.Id),
                DeweyCallNumber  = _asset.GetDeweyIndex(a.Id),
                // CopiesAvailable = _checkout.GetNumberOfCopies(a.Id), // Remove
                Title = _asset.GetTitle(a.Id),
                Type  = _asset.GetType(a.Id),
                //NumberOfCopies = _checkout.GetNumberOfCopies(a.Id)
            });

            var model = new AssetIndexModel
            {
                Assets = listingResult,
                Title  = "Library Catalog"
            };

            return(View(model));
        } //index
        public async Task <IActionResult> GetAll()
        {
            var assets = await _assets.GetAll();

            var assetsToReturn = _mapper.Map <IEnumerable <AssetForListDto> >(assets);

            return(Ok(assetsToReturn));
        }
Beispiel #9
0
        public IActionResult Index()
        {
            var assetModels  = _assets.GetAll();
            var listingModel = assetModels.Select(a => new AssetIndexListingModel()
            {
                Id               = a.Id,
                ImageUrl         = a.ImageUrl,
                AuthorOrDirector = _assets.GetAuthorOrDirector(a.Id),
                Type             = _assets.GetType(a.Id),
                DewNumber        = _assets.GetDeweyIndex(a.Id),
                Title            = a.Title
            });

            return(View(new AssetIndexModel()
            {
                Assets = listingModel
            }));
        }
        public IActionResult Index()
        {
            var assetModels = assets.GetAll();
            var listResult  = assetModels
                              .Select(result => new AssetIndexListingModel
            {
                Id               = result.Id,
                ImageUrl         = result.ImageUrl,
                AuthorOrDirector = assets.GetAuthorOrDirector(result.Id),
                Tittle           = result.Tittle,
                Type             = assets.GetType(result.Id),
            });
            var model = new AssetIndexModel()
            {
                Assets = listResult
            };

            return(View(model));
        }
        public ActionResult Index()
        {
            var assets          = _assets.GetAll();
            var assetsViewModel = assets.Select(a => new AssetViewModel
            {
                Id               = a.Id,
                ImageUrl         = a.ImageUrl,
                Title            = a.Title,
                AuthorOrDirector = _assets.GetAuthorOrDirector(a.Id),
                DeweyCallNumber  = _assets.GetDeweyIndex(a.Id),
                Type             = _assets.GetType(a.Id)
            });

            var model = new AssetIndexViewModel
            {
                Assets = assetsViewModel
            };

            return(View(model));
        }
        public IActionResult Index()
        {
            var assetModels   = _assets.GetAll();
            var listingResult = assetModels.Select(result => new AssetIndexListingModel // AssetModels is getting all the data coming from db then
            {                                                                           // project all the elements of assetModels results into a new form
                Id               = result.Id,                                           // so any type of other object that we might want to map it to in this case we map it to AssetIndexListingModel
                ImageUrl         = result.ImageUrl,
                AuthorOrDirector = _assets.GetAuthorOrDirector(result.Id),
                DeweyCallNumber  = _assets.GetDeweyIndex(result.Id),
                Title            = result.Title,
                Type             = _assets.GetType(result.Id)
            });

            var model = new AssetIndexModel()
            {                          // pass new instance of AssetIndexModel
                Assets = listingResult // pass listing results we just created to the property of the model.
            };

            return(View(model));
        }
Beispiel #13
0
        // GET: Catalog
        public ActionResult Index()
        {
            var assetModels   = _asset.GetAll();
            var listingResult = assetModels.Select(
                result => new LibraryAssetDetailsDTO()
            {
                Id               = result.Id,
                ImageUrl         = result.ImageUrl,
                AuthorOrDirector = _asset.GetAuthorOrDirector(result.Id),
                Title            = result.Title,
                Type             = _asset.GetType(result.Id),
                Year             = result.Year
            });
            var model = new LibraryAssetApi()
            {
                Asset = listingResult
            };

            return(View(model));
        }
        public IActionResult Index()
        {
            var assetModels   = _assets.GetAll();
            var listingResult = assetModels
                                .Select(a => new AssetIndexListingModel
            {
                Id               = a.Id,
                ImageUrl         = a.ImageUrl,
                AuthorOrDirector = _assets.GetAuthorOrDirector(a.Id),
                Dewey            = _assets.GetDeweyIndex(a.Id),
                Title            = _assets.GetTitle(a.Id),
                Type             = _assets.GetType(a.Id),
            }).ToList();
            var model = new AssetIndexModel
            {
                Assets = listingResult
            };

            return(View(model));
        }
Beispiel #15
0
        public IActionResult Index()
        {
            var assetmodel    = _asset.GetAll();
            var Listingresult = assetmodel
                                .Select(result => new AssetIndexListingModel()
            {
                Id              = result.Id,
                Title           = result.Title,
                ImageUrl        = result.ImageUrl,
                AuthorOrDirctor = _asset.GetDirectorOrAuthor(result.Id),
                DeweyCallNumber = _asset.GetDeweyIndex(result.Id),
                Type            = _asset.GetType(result.Id)
            });
            var model = new AssetIndexModel()
            {
                Assets = Listingresult
            };

            return(View(model));
        }
        public IActionResult Index()
        {
            var assetModels = _assets.GetAll();

            var model = assetModels.Select(
                result => new AssetIndexModel
            {
                Id               = result.Id,
                ImageUrl         = result.ImageUrl,
                Title            = result.Titel,
                NumberOfCopies   = result.NumberOfCopies,
                AuthorOrDirector = _assets.getAuthorOrDirector(result.Id),
                DeweyCallNumber  = _assets.getDeweyIndex(result.Id),
                Type             = _assets.getType(result.Id)
            }
                );


            return(View(model));
        }
Beispiel #17
0
        public IActionResult Index()
        {
            var assetModels   = _assets.GetAll();
            var listingResult = assetModels
                                .Select(result => new AssetIndexListingModel
            {
                ID               = result.ID,
                ImgUrl           = result.ImgUrl,
                AuthorOrDirector = _assets.GetAuthoreOrDirector(result.ID),
                CallNumber       = _assets.GetIndex(result.ID),
                Titel            = result.Titel,
                Type             = _assets.GetType(result.ID)
            });
            var model = new AssetIndexModel()
            {
                Assets = listingResult
            };

            return(View(model));
        }
Beispiel #18
0
        //Controller uses the service set-up (LibraryAssetService) to select into the particular
        //viewModel (AssetIndexListingModel -> AssetIndexModel) to be returned to be rendered
        public IActionResult Index()
        {
            IEnumerable <LibraryAsset>           assetModels   = _assets.GetAll();
            IEnumerable <AssetIndexListingModel> listingResult = assetModels
                                                                 .Select(result => new AssetIndexListingModel
            {
                Id               = result.Id,
                ImageUrl         = result.ImageUrl,
                AuthorOrDirector = _assets.GetAuthorOrDirector(result.Id),
                Dewey            = _assets.GetDeweyIndex(result.Id),
                Type             = _assets.GetType(result.Id),
                Title            = result.Title,
            });

            AssetIndexModel model = new AssetIndexModel()
            {
                Assets = listingResult
            };

            return(View(model));
        }
        public IActionResult Index()
        {
            var AssetModels = _assets.GetAll(); //makes data available from the getall function from the interface

            var ListingResult = AssetModels     //contains all the data that we want to present in the view
                                .Select(result => new AssetIndexListingModel
            {
                Id               = result.Id,
                ImageUrl         = result.ImageUrl,
                AuthorOrDirector = _assets.GetAuthorOrDirectorById(result.Id),
                DeweyCallNumber  = _assets.GetDeweyIndex(result.Id),
                Title            = result.Title,
                Type             = _assets.GetType(result.Id)
            });

            //var model = new AssetIndexModel()
            //{
            //  Assets = ListingResult
            //};
            return(View(ListingResult));
        }
Beispiel #20
0
        public IActionResult Index()
        {
            var listingResult = _assets.GetAll()
                                .Select(result => new AssetModel()
            {
                Id               = result.Id,
                ImageUrl         = result.ImageUrl,
                AuthorOrDirector = _assets.GetAuthorOrDirector(result.Id),
                DeweyCallNumber  = _assets.GetDeweyIndex(result.Id),
                Title            = result.Title,
                Type             = _assets.GetType(result.Id),
                NumberOfCopies   = result.NumberOfCopies
            });

            var viewModel = new CatalogIndexViewModel()
            {
                Assets = listingResult
            };

            return(View(viewModel));
        }
Beispiel #21
0
        public IActionResult Index(string title = "", string author = "")
        {
            var assetModels = _assets.GetAll()
                              .Where(a => (string.IsNullOrEmpty(title)) || (string.IsNullOrEmpty(author)) || _assets.GetAuthorOrDirecor(a.Id) == author || a.Title == title);

            var l = assetModels.Select(r => new AssetIndexListingModel
            {
                Id              = r.Id,
                ImageUrl        = r.ImageUrl,
                DeweyCallNumber = _assets.GetDewyIndex(r.Id),
                Type            = _assets.GetType(r.Id),
                Title           = r.Title
            }
                                       );
            var model = new AssetIndexModel()
            {
                Assets = l
            };

            return(View(model));
        }
        public IActionResult Index()
        {
            var assetModels = assets.GetAll();

            var model = new List <AssetIndexListingModel>();

            foreach (var item in assetModels)
            {
                var modelToAdd = new AssetIndexListingModel
                {
                    Id               = item.Id,
                    ImageUrl         = item.ImageUrl,
                    AuthorOrDirector = assets.GetAuthorOrDirector(item.Id),
                    DeweyCallNumber  = assets.GetDeweyIndex(item.Id),
                    Title            = item.Title,
                    Type             = assets.GetType(item.Id)
                };

                model.Add(modelToAdd);
            }

            //var listingResult = assetModels
            //    .Select(result => new AssetIndexListingModel
            //    {
            //        Id = result.Id,
            //        ImageUrl = result.ImageUrl,
            //        AuthorOrDirector = assets.GetAuthorOrDirector(result.Id),
            //        DeweyCallNumber = assets.GetDeweyIndex(result.Id),
            //        Title = result.Title,
            //        Type = assets.GetType(result.Id)

            //    });

            //var model = new AssetIndexModel()
            //{
            //    Assets = listingResult
            //};

            return(View(model));
        }
Beispiel #23
0
        public IActionResult Index()
        {
            var assetModel = _libraryAsset.GetAll();

            var indexListing = assetModel
                               .Select(result => new AssetIndexListingModel
            {
                Id               = result.Id,
                ImageUrl         = result.ImageUrl,
                AuthorOrDirector = _libraryAsset.GetAuthorOrDirector(result.Id),
                DeweyCallNumber  = _libraryAsset.GetDeweyIndex(result.Id),
                Title            = result.Title,
                Type             = _libraryAsset.GetType(result.Id)
            });

            var Model = new AssetViewModel()
            {
                Assets = indexListing
            };

            return(View(Model));
        }
        public IActionResult Index()        //when visit route url of website/catalog
        {
            var assetModels = _assets.GetAll();

            var listingResult = assetModels     //Select is powerful Linq feature
                                .Select(result => new AssetIndexListingModel
            {
                Id               = result.Id,
                ImageUrl         = result.ImageUrl,
                AuthorOrDirector = _assets.GetAuthorOrDirector(result.Id),
                DeweyCallNumber  = _assets.GetDeweyIndex(result.Id),
                Title            = result.Title,
                Type             = _assets.GetType(result.Id)
            });

            var model = new AssetIndexModel()
            {
                Assets = listingResult
            };

            return(View(model));
        }
        public IActionResult Index()
        {
            var assetModels = libraryAsset.GetAll();

            var listingResult = assetModels
                                .Select(result => new AssetIndexListingModel
            {
                Id               = result.Id,
                Title            = result.Title,
                ImageUrl         = result.ImageUrl,
                AuthorOrDirector = libraryAsset.GetAuthorOrDirector(result.Id),
                NumberOfCopies   = result.NumberOfCopies.ToString(),
                Type             = libraryAsset.GetType(result.Id)
            });

            var model = new AssetIndexModel()
            {
                Assets = listingResult
            };

            return(View(model));
        }
Beispiel #26
0
        public IActionResult Index()
        {
            var assetModels   = _assets.GetAll();
            var listingResult = assetModels
                                .Select(result => new AssetIndexViewModel
            {
                Id             = result.Id,
                Title          = result.Title,
                Author         = _assets.GetAuthor(result.Id),
                NumberOfCopies = result.NumberOfCopies,
                BookIndex      = _assets.GetBookIndex(result.Id),
                ImageUrl       = result.ImageUrl,
                Type           = _assets.GetType(result.Id),
            });

            var model = new AssetIndexModel()
            {
                Assets = listingResult
            };

            return(View(model));
        }
Beispiel #27
0
        public IActionResult Index()
        {
            var assetMoldes = _assets.GetAll();

            // Map the data from databse and relate it to the AssetIndexListing Model.
            var listingResult = assetMoldes.Select(result => new AssetIndexListingModel
            {
                Id               = result.Id,
                ImageUrl         = result.ImageUrl,
                Title            = result.Title,
                AuthorOrDirector = _assets.GetAuthorOrDirector(result.Id),
                DeweyCallNumber  = _assets.GetDeweyIndex(result.Id),
                Type             = _assets.GetType(result.Id)
            });

            var model = new AssetIndexModel()
            {
                Assets = listingResult
            };

            return(View(model));
        }
Beispiel #28
0
        public IActionResult Index()
        {
            ViewBag.Title = "Library Catalogue";
            var assetModels   = _asset.GetAll();
            var listingResult = assetModels
                                .Select(result => new AssetIndexListing
            {
                Id               = result.Id,
                ImageUrl         = result.ImageUrl,
                AuthorOrDirector = _asset.GetAuthorOrDirector(result.Id),
                DeweyCallNumber  = _asset.GetDeweyIndex(result.Id).ToString(),
                Title            = result.Title,
                Type             = _asset.GetType(result.Id)
            });

            var model = new AssetIndexModel()
            {
                Assets = listingResult
            };

            return(View(model));
        }
        public IActionResult Index()
        {
            var assetModels = _assets.GetAll();

            //use AutoMapper later to refactor code
            var listingResult = assetModels
                                .Select(r => new AssetIndexListingModel
            {
                Id               = r.Id,
                ImageUrl         = r.ImageUrl,
                AuthorOrDirector = _assets.GetAuthorOrDirector(r.Id),
                DeweyCallNumber  = _assets.GetDewayIndex(r.Id),
                Title            = r.Title,
                Type             = _assets.GetType(r.Id)
            });

            var vm = new AssetIndexModel()
            {
                Assets = listingResult
            };

            return(View(vm));
        }
Beispiel #30
0
        public IActionResult Index()
        {
            IEnumerable <LibraryAsset> assetModels = _assets.GetAll();


            IEnumerable <AssetIndexListingModel> listingResult = assetModels
                                                                 .Select(result => new AssetIndexListingModel
            {
                Id               = result.Id,
                Title            = result.Title,
                AuthorOrDirector = _assets.GetAuthorOrDirector(result.Id),
                ImageUrl         = result.ImageUrl,
                NumberOfCopies   = result.NumberOfCopies.ToString(),
                DeweyCallNumber  = _assets.GetDeweyIndex(result.Id),
                Type             = _assets.GetType(result.Id)
            });

            AssetIndexModel model = new AssetIndexModel();

            model.Assets = listingResult;

            return(View(model));
        }