public ActionResult Index(FrontPageViewModel model) { if (model == null) { model = new FrontPageViewModel(); } var informalCategories = context.Categories.Where(c => !c.Formell); model.Posts = context.Posts.Where(x => x.Hidden == false && informalCategories.Select(c => c.Id).Contains(x.KategoriId)).Take(1).OrderByDescending(x => x.Date).ToList(); foreach (var item in model.Posts) { model.Users.Add(context.Users.SingleOrDefault(x => x.Id == item.User)); } model.EducationPosts = context.EducationPosts.Take(1).OrderByDescending(x => x.Date).ToList(); foreach (var item in model.EducationPosts) { model.EducationUsers.Add(context.Users.SingleOrDefault(x => x.Id == item.UserId)); } model.ResearchPosts = context.ResearchPosts.Take(1).OrderByDescending(x => x.Date).ToList(); foreach (var item in model.ResearchPosts) { model.ResearchUsers.Add(context.Users.SingleOrDefault(x => x.Id == item.UserId)); } model.FormalPosts = context.Posts.Where(x => x.Hidden == false && !informalCategories.Select(c => c.Id).Contains(x.KategoriId)).Take(1).OrderByDescending(x => x.Date).ToList(); return(View(model)); }
public FrontPage(FrontPageViewModel frontPageViewModel) { InitializeComponent(); _frontPageViewModel = frontPageViewModel; BindingContext = _frontPageViewModel = new FrontPageViewModel(); }
public IActionResult Index() { var books = new FrontPageViewModel(); books.NewestBooks = _bookService.GetBooksById(); books.TopTwelve = _bookService.GetTopTwelveBooks(); return(View(books)); }
public IActionResult Index() { FrontPageViewModel VM = new FrontPageViewModel(); VM.TotalSellers = _unitofwork.Sellers.GetAll().Count(); VM.SumOfAllSales = _unitofwork.Sales.GetAll().Select(s => s.TransactionValue).Sum(); return(View(VM)); }
public ActionResult Index() { var model = new FrontPageViewModel { FeaturedMovies = _movieService.GetFeaturedMovies() }; return(View(model)); }
public void Index() { // Arrange HomeController controller = new HomeController(); // Act FrontPageViewModel model = new FrontPageViewModel(); ViewResult result = controller.Index(model) as ViewResult; // Assert Assert.IsNotNull(result); }
private FrontPageViewModel GetFrontPageViewModel(PageViewMode?mode) { var repo = new PersonalInfoRepository(); var personalInfo = repo.GetPersonalInfo(); var eduRepo = new EducationRepository(); var educations = eduRepo.GetEducations(); var expRepo = new WorkExperienceRepository(); var experience = expRepo.GetWorkExperience(); var skillsRepo = new SkillsRepository(); var skills = skillsRepo.GetSkills(); ViewBag.Mode = mode ?? PageViewMode.View; var frontPageViewModel = new FrontPageViewModel() { EducationBlock = new EducationListViewModel() { NewEducation = new EducationViewModel() }, WorkExperienceBlock = new WorkExperienceListViewModel() { NewWorkExpirience = new WorkExperienceViewModel() }, SkillCategoryBlock = new SkillsCategoryListViewModel() { NewSkillCategory = new SkillsCategoryViewModel(), } }; frontPageViewModel.PersonalInfo = new PersonalInfoViewModel(personalInfo); frontPageViewModel.EducationBlock.EducationList = educations.Select(x => new EducationViewModel(x)).ToList(); frontPageViewModel.EducationBlock.NewEducation = new EducationViewModel(); frontPageViewModel.WorkExperienceBlock.WorkExperienceList = experience.Select(x => new WorkExperienceViewModel(x)).ToList(); frontPageViewModel.WorkExperienceBlock.NewWorkExpirience = new WorkExperienceViewModel(); frontPageViewModel.SkillCategoryBlock.SkillsCategoryList = skills.Select(x => new SkillsCategoryViewModel(x)).ToList(); frontPageViewModel.SkillCategoryBlock.NewSkillCategory = new SkillsCategoryViewModel(); return(frontPageViewModel); }
public FrontPageViewModel GetHomeBooks() { var homePageList = new FrontPageViewModel { SciFi = (from b in _db.Books where b.Genre == "Science Fiction" select new BookDetailsViewModel { Id = b.Id, GoodReadsId = b.GoodReadsId, Title = b.Title, Author = b.Author, ISBN13 = b.ISBN13, Publisher = b.Publisher, PageCount = b.PageCount, YearPublished = b.YearPublished, OriginalPublicationYear = b.OriginalPublicationYear, Rating = b.Rating, Genre = b.Genre, Price = b.Price }).ToList(), Children = (from b in _db.Books where b.Genre == "Children" select new BookDetailsViewModel { Id = b.Id, GoodReadsId = b.GoodReadsId, Title = b.Title, Author = b.Author, ISBN13 = b.ISBN13, Publisher = b.Publisher, PageCount = b.PageCount, YearPublished = b.YearPublished, OriginalPublicationYear = b.OriginalPublicationYear, Rating = b.Rating, Genre = b.Genre, Price = b.Price }).ToList(), Contemporary = (from b in _db.Books where b.Genre == "Contemporary" select new BookDetailsViewModel { Id = b.Id, GoodReadsId = b.GoodReadsId, Title = b.Title, Author = b.Author, ISBN13 = b.ISBN13, Publisher = b.Publisher, PageCount = b.PageCount, YearPublished = b.YearPublished, OriginalPublicationYear = b.OriginalPublicationYear, Rating = b.Rating, Genre = b.Genre, Price = b.Price }).ToList(), Fantasy = (from b in _db.Books where b.Genre == "Fantasy" select new BookDetailsViewModel { Id = b.Id, GoodReadsId = b.GoodReadsId, Title = b.Title, Author = b.Author, ISBN13 = b.ISBN13, Publisher = b.Publisher, PageCount = b.PageCount, YearPublished = b.YearPublished, OriginalPublicationYear = b.OriginalPublicationYear, Rating = b.Rating, Genre = b.Genre, Price = b.Price }).ToList(), YoungAdult = (from b in _db.Books where b.Genre == "Young Adult" select new BookDetailsViewModel { Id = b.Id, GoodReadsId = b.GoodReadsId, Title = b.Title, Author = b.Author, ISBN13 = b.ISBN13, Publisher = b.Publisher, PageCount = b.PageCount, YearPublished = b.YearPublished, OriginalPublicationYear = b.OriginalPublicationYear, Rating = b.Rating, Genre = b.Genre, Price = b.Price }).ToList() }; return(homePageList); }
public async Task <OfferRenderViewModel> FillViewModel(Guid Id, OfferRenderViewModel offerrender) { ICollection <EstimateConnects> Connect; ICollection <Offers> offers; using (var context = new DataBaseContext()) { offers = context.Offer .Include(offermodel => offermodel.Estimate) .Include(users => users.CreatedBy) .Include(users => users.UpdatedBy) .ToList(); Connect = context.EstimateConnects .Include(line => line.EstimateLines) .ToList(); } Offers offer = await OfferRepository.FindAsync(Id); var dboffer = offers.FirstOrDefault(x => x.Id.Equals(Id)); var estimate = await EstimateRepository.FindAsync(dboffer.Estimate.Id); var connectlines = Connect.Where(x => x.Estimate.Id.Equals(dboffer.Estimate.Id)).ToList(); float exclbtw = 0; float btw = 0; float totalcost = 0; foreach (var item in connectlines) { exclbtw = exclbtw + item.EstimateLines.TotalCost; } btw = exclbtw / 100 * 21; totalcost = exclbtw + btw; #region var Page3ViewModel = new Page3ViewModel { CustomerZipCode = "7957EJ", CustomerStreet = "Oosterakker 21", CustomerName = "K.Broekstra", CustomerCompany = "Broekstra B.V.", CustomerEmail = "*****@*****.**", DocumentVersion = offer.DocumentVersion }; var FrontPageViewModel = new FrontPageViewModel { CreatedBy = dboffer.CreatedBy.FirstName + " " + dboffer.CreatedBy.LastName, LastUpdated = offer.LastUpdatedAt.ToString(), ProjectName = offer.ProjectName, DocumentCode = offer.DocumentCode, CustomerZipCode = "7957EJ", CustomerStreet = "Oosterakker 21", CustomerName = "K.Broekstra", CustomerCompany = "Broekstra B.V.", CustomerCountry = "The Netherlands" }; var EstimateTablePage = new EstimateTablePage { EstimateConnects = connectlines, BTW = btw.ToString("#,##0.00"), ExclBtw = exclbtw.ToString("#,##0.00"), Totaal = totalcost.ToString("#,##0.00") }; offerrender.EstimateTablePage = EstimateTablePage; offerrender.FrontPage = FrontPageViewModel; offerrender.Page3 = Page3ViewModel; #endregion return(offerrender); }
public FrontPage() { this.InitializeComponent(); ViewModel = new FrontPageViewModel(); NavigationCacheMode = NavigationCacheMode.Enabled; }