Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
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));
        }
Ejemplo n.º 3
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();
        }
Ejemplo n.º 4
0
        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));
        }
Ejemplo n.º 5
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
Ejemplo n.º 6
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));
     }
 }
Ejemplo n.º 7
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
            }));
        }
Ejemplo n.º 8
0
 public AssetIndexListingModel(LibraryAsset result, ILibraryAsset assets) : this(result)
 {
     //this.Id = result.Id;
     //this.ImageUrl = result.ImageUrl;
     //this.Title = result.Title;
     AuthorOrDirector = assets.GetAuthorOrDirector(result.Id);
     DeweyCallNumber  = assets.GetDeweyIndex(result.Id);
     Type             = assets.GetType(result.Id);
 }
        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));
        }
        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));
        }
Ejemplo n.º 12
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));
        }
Ejemplo n.º 13
0
        public IActionResult Index()
        {
            var models = _interface.GetAllAssets();

            var listingResult = models.Select(e => new AssetIndexListingModel
            {
                ID               = e.ID,
                imageUrl         = e.ImageUrl,
                title            = e.Title,
                authorOrDirector = _interface.GetAuthorOrDirector(e.ID),
                deweyCallNumber  = _interface.GetDeweyIndex(e.ID),
                type             = _interface.GetType(e.ID)
            });

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

            return(View(model));
        }
Ejemplo n.º 14
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));
        }
Ejemplo n.º 15
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));
        }
        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));
        }
        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));
        }
Ejemplo n.º 18
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));
        }
Ejemplo n.º 19
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));
        }
Ejemplo n.º 20
0
        public IActionResult Index()
        {
            var assetModel = _assets.GetAllLibraryAssets();

            var displayAssets = assetModel
                                .Select(result => new AssetIndexListingModel
            {
                Id               = result.Id,
                ImageUrl         = result.ImgUrl,
                Title            = result.Title,
                AuthorOrDirector = _assets.GetAuthorOrDirector(result.Id),
                DeweyIndex       = _assets.GetDeweyIndex(result.Id),
                NumberOfCopies   = result.NumberOfCopies,
                Type             = _assets.GetType(result.Id)
            });

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

            return(View(model));
        }
Ejemplo n.º 21
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));
        }
Ejemplo n.º 22
0
        /**
         * localhost:44338/Catalog/
         */
        public IActionResult Index()
        {
            var assetModels = _assets.GetAll();

            // Maps data from assetModels to anonimus class
            // AssetIndexListingModel one to one.
            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()
            {// Contains AssetIndexListingModel
                Assets = listingResult
            };

            return(View(model));
        }
Ejemplo n.º 23
0
        public IActionResult Index()
        {
            //Gets list of all assets
            var assetModels = _assets.GetAll();
            //Stores list of assets in to a model, displaying select fields
            var listingResult = assetModels.Select(result => new AssetsIndexListingModel
            {
                Id              = result.Id,
                ImageUrl        = result.ImageUrl,
                AuthOrDirector  = _assets.GetAuthorOrDirector(result.Id),
                DeweyCallNumber = _assets.GetDeweyIndex(result.Id),
                Title           = result.Title,
                Type            = _assets.GetType(result.Id)
            });

            //Creates a separate model for the index, assigns the above view model to this view model, allows for more modularity and a layer of abstraction
            var model = new AssetIndexModel()
            {
                Assets = listingResult
            };

            //returns the index model
            return(View(model));
        }
Ejemplo n.º 24
0
        // GET: Catalog
        public async Task <ActionResult> Index()
        {
            var assets = await _assets.GetAll();

            var assetsModelTasks = assets.Select(async a => {
                var newAsset = new AssetIndexViewModel
                {
                    Id               = a.Id,
                    ImgUrl           = a.ImgUrl,
                    Title            = a.Title,
                    AuthorOrDirector = await _assets.GetAuthorOrDirector(a.Id),
                    Type             = await _assets.GetType(a.Id),
                    DeweyNumber      = await _assets.GetDeweyIndex(a.Id),
                    NumberOfCopies   = a.NumberOfCopies
                };
                return(newAsset);
            });

            AssetIndexViewModel[] assetModel = await Task.WhenAll(assetsModelTasks);



            return(View(assetModel.ToList()));
        }
Ejemplo n.º 25
0
        public IActionResult Index()
        {
            var allAssets     = _assets.GetAll();
            var ListingResult = allAssets
                                .Select(
                asset =>
                new AssetIndexListingModel {
                id               = asset.Id,
                ImageUrl         = asset.ImageUrl,
                Title            = asset.Title,
                AuthorOrDirector = _assets.GetAuthorOrDirector(asset.Id),
                Type             = _assets.GetType(asset.Id),
                DeweyCallNumber  = _assets.GetDeweyIndex(asset.Id),
                NumberOfCopies   = asset.NumberOfCopies
            }
                ).ToList();

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

            return(View(model));
        }
Ejemplo n.º 26
0
        public IActionResult Detail(int id)
        {
            var asset = _assets.GetById(id);

            var model = new AssetDetailModel
            {
                AssetId          = id,
                Title            = asset.Title,
                Year             = asset.Year,
                Cost             = asset.Cost,
                Status           = asset.Status.Name,
                ImageUrl         = asset.ImageUrl,
                AuthorOrDirector = _assets.GetAuthorOrDirector(id),
                CurrentLocation  = _assets.GetCurrentLocation(id).Name,
                DeweyCallNumber  = _assets.GetDeweyIndex(id),
                ISBN             = _assets.GetIsbn(id)
            };

            return(View(model));
        }
Ejemplo n.º 27
0
        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));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 29
0
        public IActionResult Index()
        {
            var assetModels = _asset.GetAll();


            //This is for dependency injection
            var listingResult = assetModels
                                .Select(result => new AssetIndexListingModel
            {
                Id               = result.Id,
                ImageUrl         = result.ImageUrl,
                AuthorOrDirector = _asset.GetAuthorOrDirector(result.Id),
                DeweyCallNumber  = _asset.GetDeweyIndex(result.Id)
            });


            var model = new AssetIndexModel
            {
                Assets = listingResult
            };

            return(View(model));
        }