public GetMagazineViewModel GetAll() { var magazineEntities = _magazineRepository.GetAll(); var magazineViews = new GetMagazineViewModel(); magazineViews.Magazines = Mapper.Map <IEnumerable <Magazine>, List <GetMagazineViewItem> >(magazineEntities); return(magazineViews); }
public GetMagazineViewModel Get(long id) { var magazine = _magazineRepository.Get(id); if (magazine == null) { throw new BusinessLogicException("Magazine not found"); } var result = new GetMagazineViewModel() { Id = magazine.Id, Name = magazine.Name, Number = magazine.Number, YearOfPublication = magazine.YearOfPublication }; return(result); }
public IActionResult Get() { GetMagazineViewModel listMagazines = _magazineService.GetAll(); return(Ok(listMagazines)); }