//public AdministratorController(LaptopRepository repository) //{ // if (repository == null) throw new Exception("Administrator controller requires a repository"); // this.repository = repository; //} public IEnumerable GetLaptopCategory() { LaptopService service = new LaptopService(repository); return (from laptopCategory in service.GetLaptops() select new { Name = laptopCategory.Name }).Distinct(); }
public IEnumerable GetLaptopDetails(string Name) { LaptopService service = new LaptopService(repository); return (from laptopDetails in service.GetLaptops() where laptopDetails.Name == Name select new { ID = laptopDetails.ID, Description = laptopDetails.Description }); }
public Laptop GetLaptopConfiguration(int ID) { LaptopService service = new LaptopService(repository); return (from laptopDetails in service.GetLaptops() where laptopDetails.ID == ID select laptopDetails).FirstOrDefault(); }
public ActionResult Index() { LaptopService service = new LaptopService(repository); var laptops = service.GetLaptops(); var model = new LaptopsViewModel(); model.Laptops = new List<LaptopViewModel>(); foreach (var laptop in laptops) { var lvm = new LaptopViewModel(laptop); model.Laptops.Add(lvm); } return View(model); }