public IList <MagazineViewModel> GetMagazines() { Save.SaveItems(_magazineRepository.GetAll(), "../Magazines"); var magazines = Mapper.Map <IList <Magazine>, IList <MagazineViewModel> >(_magazineRepository.GetAll()); return(magazines); }
public ActionResult Create() { // Get magazines for correct display for magazine select on create edition page var magazines = _magazineRepository.GetAll(); ViewBag.MagazineTitles = magazines.Select(a => a.MagazineName); // Get topics for correct display for topic select on create edition page var topics = _topicRepository.GetAll(); ViewBag.Topics = topics.Select(a => a.TopicName); return(View()); }
public IEnumerable <MagazineViewModel> GetAll() { List <Magazine> magazines = _magazineRepository.GetAll().ToList(); var result = Mapper.Map <List <Magazine>, List <MagazineViewModel> >(magazines); return(result); }
public IEnumerable <MagazineEntry> GetAllProducts() { using (var repository = new MagazineRepository()) { var a = repository.GetAll().ToList(); return(a); } }
public GetMagazineViewModel GetAll() { var magazineEntities = _magazineRepository.GetAll(); var magazineViews = new GetMagazineViewModel(); magazineViews.Magazines = Mapper.Map <IEnumerable <Magazine>, List <GetMagazineViewItem> >(magazineEntities); return(magazineViews); }
public async Task <GetAllMagazineViewModel> GetAll() { var result = new GetAllMagazineViewModel(); IEnumerable <Magazine> magazinesList = await _magazineRepository.GetAll(); var magazineVMItemList = Mapper.Map <IEnumerable <Magazine>, List <MagazineGetAllMagazineViewModelItem> >(magazinesList); result.Magazines = magazineVMItemList; return(result); }
public GetMagazineView GetAll() { var magazineViewModel = new GetMagazineView(); var allMagazinesModel = _magazineRepository.GetAll(); List <MagazineGetMagazineViewItem> allMagazinesViewModel = Mapper.Map <List <Magazine>, List <MagazineGetMagazineViewItem> >(allMagazinesModel); magazineViewModel.Magazines = allMagazinesViewModel; return(magazineViewModel); }
public IHttpActionResult Synchronize() { bool success = true; try { using (var repository = new MagazineRepository()) { var listOfMagazineEntries = repository.GetAll(); for (int i = 0; i < SERVICE_URLS.Length; i++) { IList <UnitEntry> list; try { var client = GetWebClient(SERVICE_URLS[i]); list = client.Unit.GetAllProducts(); } catch (HttpRequestException e) { Console.WriteLine("Cannot connect to the " + SERVICE_LOCATIONS[i] + "reason: " + e.ToString()); continue; } var entiresToRemove = listOfMagazineEntries.Where(x => x.Localization == SERVICE_LOCATIONS[i]); _log.InfoFormat("entiresToRemove"); foreach (var entry in entiresToRemove) { _log.InfoFormat($"{entry.Id.ToString()}"); repository.Remove(entry.Id); } foreach (var unitEntry in list) { MagazineEntry entry = new MagazineEntry(unitEntry.Name, unitEntry.Count.GetValueOrDefault(), SERVICE_LOCATIONS[i]); repository.Add(entry); } } synchronize = true; } } catch (System.Net.Http.HttpRequestException e) { success = false; synchronize = false; } if (success) { return(Ok()); } return(InternalServerError(new Exception("Cannot connect to unit webservice"))); }
private IEnumerable <Publication> GetAllPublications() { _publicationList = new List <Publication>(); _publicationList = _bookRepository.GetAll().Select(x => new Publication { Name = x.Name, Type = PublicationType.Book }) .Concat(_brochureRepository.GetAll().Select(x => new Publication { Name = x.Name, Type = PublicationType.Brochure })) .Concat(_magazineRepository.GetAll().Select(x => new Publication { Name = x.Name, Type = PublicationType.Magazine })); return(_publicationList); }
public IHttpActionResult RemoveAllMagazineProducts() { using (var repository = new MagazineRepository()) { var products = repository.GetAll(); foreach (var product in products) { if (repository.RemoveAll() == false) { return(BadRequest()); } } } return(Ok()); }
public IEnumerable <LibraryViewModel> GetLibrary() { List <Book> books = _bookRepository.GetAll().ToList(); var viewBooks = Mapper.Map <List <Book>, List <LibraryViewModel> >(books); List <Brochure> brochures = _brochureRepository.GetAll().ToList(); var viewBrochures = Mapper.Map <List <Brochure>, List <LibraryViewModel> >(brochures); List <Magazine> magazines = _magazineRepository.GetAll().ToList(); var viewMagazines = Mapper.Map <List <Magazine>, List <LibraryViewModel> >(magazines); List <LibraryViewModel> library = new List <LibraryViewModel>(); library.AddRange(viewBooks); library.AddRange(viewBrochures); library.AddRange(viewMagazines); return(library); }
public GetAllPublicationView GetAll() { var allPublicationsViewModel = new GetAllPublicationView(); var allBooks = new List <Book>(); allBooks = _bookRepository.GetAll(); var allMagazines = new List <Magazine>(); allMagazines = _magazineRepository.GetAll(); var allBrochures = new List <Brochure>(); allBrochures = _brochureRepository.GetAll(); var allPublicationsModel = new List <PublicationGetAllPublicationView>(); foreach (var book in allBooks) { allPublicationsModel.Add(new PublicationGetAllPublicationView() { Id = book.Id, Name = book.Name, Type = nameof(Book) }); } foreach (var magazine in allMagazines) { allPublicationsModel.Add(new PublicationGetAllPublicationView() { Id = magazine.Id, Name = magazine.Name, Type = nameof(Magazine) }); } foreach (var brochure in allBrochures) { allPublicationsModel.Add(new PublicationGetAllPublicationView() { Id = brochure.Id, Name = brochure.Name, Type = nameof(Brochure) }); } allPublicationsViewModel.Publications = allPublicationsModel; return(allPublicationsViewModel); }
public GetPublicationViewModel GetAll() { var publicationView = new List <GetPublicationViewItem>(); var bookEntities = _bookRepository.GetAll(); var magazineEntities = _magazineRepository.GetAll(); var brochureEntities = _brochureRepository.GetAll(); var bookViews = Mapper.Map <IEnumerable <Book>, List <GetBookViewItem> >(bookEntities); var magazineViews = Mapper.Map <IEnumerable <Magazine>, List <GetMagazineViewItem> >(magazineEntities); var brochureViews = Mapper.Map <IEnumerable <Brochure>, List <GetBrochureViewItem> >(brochureEntities); publicationView.AddRange(bookViews); publicationView.AddRange(magazineViews); publicationView.AddRange(brochureViews); var result = new GetPublicationViewModel(); result.Publications = publicationView; return(result); }
public GetMagazineViewModel GetAll() { IEnumerable <Magazine> magazinesList = _magazineRepository.GetAll(); return(Mapper.Map <IEnumerable <Magazine>, GetMagazineViewModel>(magazinesList)); }
public void Test_GetAllMagazineZero() { Assert.AreEqual(_magazineRepository.GetAll().Count, 0); }