// GET: Animals public ActionResult Index(FilterModel search) { //ApplicationDbContext context = new ApplicationDbContext(); //List<AnimalVM> model = context.Animals.Select(a => // new AnimalVM // { // Id=a.Id, // Name=a.Name, // ImageUrl=a.UrlLink // }).ToList(); IEnumerable <Animal> list; if (search.Name != null) { list = repo.GetAll(x => x.Name.Contains(search.Name)); } else { list = repo.GetAll(); } var mapper = MyAutoMapperConfig.GetAutoMapper(); // сопоставление var model = mapper.Map <List <AnimalVM> >(list); return(View(model)); }
// GET: Photo/Edit/5 public ActionResult Edit(int id) { Product product = _productRepository.Get(id); var mapper = MyAutoMapperConfig.GetAutoMapper(); // сопоставление var model = mapper.Map <ProductAddVM>(product); return(View(model)); }
// GET: Photo public ActionResult Index() { IEnumerable <Photo> list = dataContext.Photos.ToList(); var mapper = MyAutoMapperConfig.GetAutoMapper(); // сопоставление var model = mapper.Map <List <PhotoVM> >(list); return(View(model)); }
// GET: Photo/Edit/5 public ActionResult Edit(int id) { Photo item = dataContext.Photos.Find(id); var mapper = MyAutoMapperConfig.GetAutoMapper(); // сопоставление var model = mapper.Map <PhotoAddVM>(item); return(View(model)); }
public ActionResult Create() { ProductAddVM model = new ProductAddVM(); var categories = _categoryRepository.GetAll(); var mapper = MyAutoMapperConfig.GetAutoMapper(); // сопоставление var select = mapper.Map <List <SelectItemVM> >(categories); model.SetCategoriesSelect(select); return(View(model)); }
// GET: Category public ActionResult Index(FilterModel search) { //ViewBag.Title = "Категорії --"; IEnumerable <Product> list; if (search.Name != null) { list = _productRepository.GetAll(x => x.Name.Contains(search.Name)); } else { list = _productRepository.GetAll(); } var mapper = MyAutoMapperConfig.GetAutoMapper(); // сопоставление var model = mapper.Map <List <ProductVM> >(list); return(View(model)); }