public void SetPriceWithNegativeValue() { float price = -10; var model = new HomePageVM(); Assert.ThrowsException <ArgumentException>(() => model.SetPrice(price)); }
public HomePage(int i) { InitializeComponent(); HomePageVM = new HomePageVM(); BindingContext = HomePageVM; Detail = new NavigationPage(new NoResponsePage()); }
internal HomePageVM GetOrganisationsFromDB() { //OrganisationsVM OrganisationsToShow = new OrganisationsVM(); var allTags = GetTagsFromDB(); var allOrganizationTags = _context.OrganizationsTags.ToList(); var organisations = _context.Organizations .Select(c => new OrganisationVM { Name = c.Name, Logo = c.Logo, Description = c.Description, Type = c.Type, Summary = c.Summary, Id = c.Id, Email = c.Email, Info = c.Info, Website = c.Website, Tags = GetTagsForThisOrganization(c.Id, allTags, allOrganizationTags), Approve = c.Approve }) .ToArray(); HomePageVM homePageInfo = new HomePageVM(); homePageInfo.OrganisationArray = organisations; return(homePageInfo); }
public void SetOrdersStatisticsTwoElementListTest() { var order1 = new Order() { Amount = 10, Customer = new Customer() { FirstName = "TestFirst", LastName = "TestLast" }, DateOfRealization = DateTime.Now, }; var order2 = new Order() { Amount = 20, Customer = new Customer() { FirstName = "TestFirst2", LastName = "TestLast2" }, DateOfRealization = DateTime.Now.AddDays(-1) }; var orders = new List <Order>() { order1, order2 }; var model = new HomePageVM(); model.SetOrdersStatistics(orders); Assert.AreEqual($"1. {order2}", model.WaitingRoom1); Assert.AreEqual($"2. {order1}", model.WaitingRoom2); Assert.AreEqual("", model.WaitingRoom3); Assert.AreEqual($"Sprzedane kilogramy: 0", model.SoldedInfo); }
// // GET: /Home/ public ActionResult Index() { var vm = new HomePageVM(); var svc = Service; var tenant = svc.SelectOrEmpty(new TenantQuery() { IDs = new long[] { UserID }, Includes = new [] { "Owner", "Owner.Config" } }).FirstOrDefault(); vm.EmailVerified = tenant.EmailVerified ?? false; vm.UsedTime = DateTime.Now - (tenant.CreatedAt ?? DateTime.Now); vm.Account = tenant.Account; vm.Type = (TenantAccountType)tenant.AccountType.Value; vm.MobileVerified = tenant.MobileVerified ?? false; if (tenant.Owner != null && tenant.Owner.Config != null) { vm.TradeCount = tenant.Owner.Config.TradeCount ?? 0; } var paymentMethod = svc.SelectOrEmpty(new PaymentMethodConfigQuery() { OwnerIDs = new long[] { OwnerID } }).FirstOrDefault(); vm.AlipayAccountBinded = (paymentMethod != null); return(View(vm)); }
public async Task <IActionResult> Create(HomePageVM homePageVM) { if (!ModelState.IsValid) { return(View(homePageVM)); } List <IFormFile> files = new List <IFormFile>(); foreach (var item in homePageVM.ProductPhotos) { if (item == null) { ModelState.AddModelError("ProductPhoto", "Image should be selected"); return(View(homePageVM)); } if (!item.IsImage()) { ModelState.AddModelError("ProductPhoto", "Image type is not valid"); return(View(homePageVM)); } if (!item.IsSmaller(1)) { ModelState.AddModelError("ProductPhoto", "Image size can be maximum 1 mb"); return(View(homePageVM)); } files.Add(item); } await _context.Products.AddAsync(new Product { Name = homePageVM.Product.Name, Price = homePageVM.Product.Price, HasDiscount = homePageVM.Product.HasDiscount, DiscountedPrice = homePageVM.Product.DiscountedPrice, Color = homePageVM.Product.Color, Availability = homePageVM.Product.Availability, Status = true, InStock = homePageVM.Product.InStock, BrandId = homePageVM.Product.BrandId }); await _context.SaveChangesAsync(); var ProId = _context.Products.LastOrDefault().Id; foreach (var item in files) { var Image = await item.SaveFileAsync(_env.WebRootPath, "images"); await _context.Images.AddAsync(new Image { ProductImage = Image, ProductId = ProId }); await _context.SaveChangesAsync(); } return(RedirectToAction(nameof(Index))); }
public ActionResult RenderCitiesMenuView() { HomePageVM model = new HomePageVM(); model.cityLists = objAPI.GetAllRecords <CityList>("webrequest", "getcitylist"); return(PartialView("_pvCitiesMenu", model)); }
public async Task <IActionResult> Delete(int?id) { if (_context.Products.Count() <= 2) { return(RedirectToAction(nameof(Index))); } if (id == null) { return(NotFound()); } Product product = await _context.Products.FindAsync(id); var image = _context.Images.Where(i => i.ProductId == id).ToList(); HomePageVM homePageVM = new HomePageVM() { Product = product, Images = image, Products = _context.Products.Include(s => s.Brand).ToList() }; if (homePageVM.Product == null) { return(NotFound()); } return(View(homePageVM)); }
public ActionResult Index(int?page) { HomePageVM hpVM = new HomePageVM(); var userId = HttpContext.User.Identity.GetUserId(); //Sätter pagenumber till 0 om värdet är null int pageNumber = (page ?? 0); var searchDate = DateTime.Now.AddDays(pageNumber); if (pageNumber != 0) { searchDate = DateTime.Now.AddDays(pageNumber).Date; } var tomorrow = searchDate.AddDays(1).Date; var newContext = new SalamiTVDB(); //Hämtar higlightade program (aka puffar) hpVM.HighlightedProgram = newContext.TvChannels.SelectMany(x => x.TvPrograms).Where(x => x.IsInFocus == true).ToList(); // LazyLoading = false; för att det första statementet måste exikviera för att det ska kunna användas i den andra funktionen. dbContext.Configuration.LazyLoadingEnabled = false; hpVM.TvChannels = dbContext.TvChannels.Select(c => new { c, programs = c.TvPrograms.Where(p => searchDate <= p.Broadcasting && p.Broadcasting <= tomorrow).GroupBy(p => p.Broadcasting) /*ASC == default*/ }).ToList().Select(x => x.c).ToList(); return(View(hpVM)); }
public HomePage() { InitializeComponent(); HomePageVM = new HomePageVM(); BindingContext = HomePageVM; Detail = new NavigationPage(new MasterHomePage()); }
public ActionResult Index() { string connectionStringName = Settings.getConnectionStringName(); List <spDesktopDataAdmin_SelectSystemUserUserProfiles_v1Result> adminUserProfiles = new List <spDesktopDataAdmin_SelectSystemUserUserProfiles_v1Result>(); adminUserProfiles = homeRepository.GetAdminUserProfiles(); string currentUserProfileIdentifier = ""; if (adminUserProfiles.Count > 0) { currentUserProfileIdentifier = adminUserProfiles[0].CurrentUserProfileIdentifier; } GenericSelectListVM connectionSelectListVM = new GenericSelectListVM(); connectionSelectListVM.SelectList = new SelectList(homeRepository.SelectListConnectionStrings().ToList(), "Value", "Name", connectionStringName); connectionSelectListVM.Message = "You are currently using the " + connectionStringName + " connection"; HomePageVM homePageVM = new HomePageVM(); homePageVM.ConnectionSelectList = connectionSelectListVM; homePageVM.UserProfileList = adminUserProfiles; homePageVM.SystemUserGuid = User.Identity.Name.Split(new[] { '|' })[0]; //homePageVM.UserProfileIdentifier = User.Identity.Name; homePageVM.UserProfileList = adminUserProfiles; homePageVM.UserNewSelectList = new SelectList(homeRepository.GetAdminUserProfiles().ToList(), "SystemUserGuid", "UserProfileIdentifier", homePageVM.SystemUserGuid); homePageVM.MappingQualityCodes = new SelectList(homeRepository.GetAdminUserProfiles().ToList(), "SystemUserGuid", "UserProfileIdentifier", homePageVM.SystemUserGuid); try { string adminUserGuid = User.Identity.Name.Split(new[] { '|' })[0]; SystemUserRepository systemUserRepository = new SystemUserRepository(); SystemUser systemUser = systemUserRepository.GetUserBySystemUserGuid(adminUserGuid); if (systemUser == null) { ViewData["Message"] = "Your ID ( " + adminUserGuid + " ) does not exist in this database, therefore you have read-only access"; } else { string username = systemUser.FirstName + " " + systemUser.LastName; if (currentUserProfileIdentifier == "" || currentUserProfileIdentifier == null) { ViewData["Message"] = "Welcome " + username + " ( ID: " + adminUserGuid + ")"; } else { ViewData["Message"] = "Welcome " + username + " ( ID: " + adminUserGuid + ", Profile: " + currentUserProfileIdentifier + ")"; } } } catch (Exception ex) { ViewData["Message"] = ex.Message; } return(View(homePageVM)); }
public void SetPriceWithPositiveValue() { float price = 10; var model = new HomePageVM(); model.SetPrice(10); Assert.AreEqual($"Cena za kilogram: {price}", model.PricePerKgInfo); }
public async Task <ActionResult> Index() { var model = new HomePageVM { NextEvent = await _eventsAppService.NextAvailable() }; return(View(model)); }
public void SetOrdersHarvestEmptyListTest() { var harvests = new List <Harvest>(); var model = new HomePageVM(); model.SetHarvestStatistics(harvests); Assert.AreEqual($"Zebrane kilogramy: 0", model.DropedInfo); }
public IActionResult Index() { HomePageVM homePageVM = new HomePageVM() { Brands = _context.Brands.Where(s => s.Status == true).ToList() }; return(View(homePageVM)); }
public IActionResult Index() { HomePageVM homePageVM = new HomePageVM() { Products = _context.Products.Where(s => s.Status == true).Include(c => c.Images).Include(s => s.Brand).ToList() }; return(View(homePageVM)); }
public ActionResult Index() { var model = new HomePageVM { Categories = db.Categories.ToList() }; return(View(model)); }
public HomePage() { InitializeComponent(); homepageVM = new HomePageVM(); //set page Title Title = "Home Page"; // set the binding context this.BindingContext = homepageVM; }
public IActionResult Create() { HomePageVM homePageVM = new HomePageVM() { Product = new Models.Product() }; ViewBag.Brands = new SelectList(_context.Brands, "Id", "Name"); return(View(homePageVM)); }
// GET: /<controller>/ public IActionResult Index() { //var model = new Restaurant { Id = 1, Name = "The Bakery" }; var model = new HomePageVM(); model.Restaurants = _restaurantData.GetAll(); model.CurrentGreeting = _greeter.GetGreeting(); return(View("Index", model)); }
public IActionResult Index() { HomePageVM home_vm = new HomePageVM() { VmSliders = iworkUnit.Slider.GetAll(), VmArticles = iworkUnit.Article.GetAll() }; return(View(home_vm)); }
public IActionResult ProductDetails(int id) { HomePageVM homePageVM = new HomePageVM() { Images = _context.Images.Where(v => v.ProductId == id).ToList(), Product = _context.Products.Include(p => p.Brand).Where(x => x.BrandId == x.Brand.Id).FirstOrDefault(v => v.Id == id) }; return(View(homePageVM)); }
public async Task <IActionResult> Edit(HomePageVM homePageVM) { Product product = await _context.Products.FindAsync(homePageVM.Product.Id); var image = _context.Images.Where(i => i.ProductId == product.Id).ToList(); HomePageVM homePageVMs = new HomePageVM() { Product = product, Images = image }; if (!ModelState.IsValid) { return(View(homePageVMs)); } var productDb = await _context.Products.FindAsync(homePageVM.Product.Id); if (homePageVM.ProductPhotos != null) { try { var ImgList = _context.Images.Where(v => v.ProductId == productDb.Id).ToList(); for (int i = 0; i < homePageVM.ProductPhotos.Count; i++) { IFormFileExstensions.Delete(_env.WebRootPath, "images", ImgList[i].ProductImage); var newPhoto = await homePageVM.ProductPhotos[i].SaveFileAsync(_env.WebRootPath, "images"); ImgList[i].ProductImage = newPhoto; _context.SaveChanges(); } } catch (Exception e) { ModelState.AddModelError("", "Unexpected error happened while saving image. Please, try again."); return(View(homePageVMs)); } } productDb.Name = homePageVM.Product.Name; productDb.Price = homePageVM.Product.Price; productDb.HasDiscount = homePageVM.Product.HasDiscount; productDb.DiscountedPrice = homePageVM.Product.DiscountedPrice; productDb.Color = homePageVM.Product.Color; productDb.Availability = homePageVM.Product.Availability; productDb.Status = true; productDb.InStock = homePageVM.Product.InStock; productDb.BrandId = homePageVM.Product.BrandId; await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); }
public ActionResult Index() { HomePageVM homePageViewModel = new HomePageVM() { AllTimeLeaderboard = GetAllTimeLeaderboard(), MonthLeaderboard = GetMonthLeaderboard(), RecentGames = GetRecentGames() }; return(View(homePageViewModel)); }
public void SetOrdersStatisticsEmptyListTest() { var orders = new List <Order>(); var model = new HomePageVM(); model.SetOrdersStatistics(orders); Assert.AreEqual("", model.WaitingRoom1); Assert.AreEqual("", model.WaitingRoom2); Assert.AreEqual("", model.WaitingRoom3); Assert.AreEqual($"Sprzedane kilogramy: 0", model.SoldedInfo); }
public IActionResult Index() { Greeting greeting = _db.Greetings.FirstOrDefault(); HomePageVM hPageVM = new HomePageVM { prevImage = greeting.Image, Header = greeting.Header, Content = greeting.Content }; return(View(hPageVM)); }
public ActionResult Index() { HomePageVM viewModel = new HomePageVM(); if (TempData["PopUp"] != null) { viewModel.Message = (string)TempData["PopUp"]; } viewModel.ContributorCount = manager.TotalContributors(); viewModel.Simchas = manager.SimchaList(); return(View(viewModel)); }
public IActionResult OurProducts() { HomePageVM homePageVM = new HomePageVM() { Brands = _context.Brands.Where(s => s.Status == true).ToList(), Products = _context.Products.Include(c => c.Images).Take(4).ToList() }; ViewBag.Brands = new SelectList(_context.Brands.Where(s => s.Status == true), "Id", "Name"); ViewData["total_products_count"] = _context.Products.Count(); return(View(homePageVM)); }
//private int kisiler; // GET: Home public ActionResult HomePage() { DatabaseContext db = new DatabaseContext(); //List<Kisi> kisiler = db.kisiler.ToList(); //List<Adres> adresler = db.adresler.ToList(); HomePageVM model = new HomePageVM(); model.Adresler = db.adresler.ToList();; model.Kisiler = db.kisiler.ToList();; return(View(model)); }
public HomePage() { this.InitializeComponent(); var vm = new HomePageVM() { ForegroundBrushOn = Util.GetSolidColorBrush(AppSettings.FontColorOn), ForegroundBrushOff = Util.GetSolidColorBrush(AppSettings.FontColorOff), ItemBackgroundBrush = Util.GetSolidColorBrush(AppSettings.ItemBackgroundColor) }; this.DataContext = vm; }