public ActionResult Details(int Id) { var vm = new DetailsVM(); vm.SetVehicle(ManagerFactory.Create(), Id); return(View(vm)); }
public IActionResult DetailsPost(int id, DetailsVM detailsVM) { List <ShoppingCart> shoppingCartList = new List <ShoppingCart>(); if (HttpContext.Session.Get <IEnumerable <ShoppingCart> >(WC.SessionCart) != null && HttpContext.Session.Get <IEnumerable <ShoppingCart> >(WC.SessionCart).Count() > 0) { //if there are products in the session and user is not logged in shoppingCartList = HttpContext.Session.Get <List <ShoppingCart> >(WC.SessionCart); } shoppingCartList.Add(new ShoppingCart { ProductId = id, Qty = detailsVM.Product.TempQty }); HttpContext.Session.Set(WC.SessionCart, shoppingCartList); if (User.IsInRole(WC.CustomerRole)) { var claimsIdentity = (ClaimsIdentity)User.Identity; var claim = claimsIdentity.FindFirst(ClaimTypes.NameIdentifier); _cartRepo.Add(new Cart { ProductId = id, Qty = detailsVM.Product.TempQty, ApplicationUserId = claim.Value }); _cartRepo.Save(); } TempData[WC.Success] = "Item add to cart successfully"; return(RedirectToAction(nameof(Index))); }
private void SelectedNodeChangedHandler() { if (SelectedNodeVM.IsLastLevel) { string query = string.Format("{0}={1},{2}", SelectedNodeVM.Node.Level_id, SelectedNodeVM.Node.Name, GetParentValues(SelectedNodeVM.Parent)); var documents = DocumentService.ReadDocuments((int)settings.presentation, SelectedNodeVM.Node.Level_id, query); if (documents != null && documents.Count > 0) { DetailsVM.Documents = new ObservableCollection <DocumentVM>(DetailsVM.ConvertDocumentToDocumentVM(documents)); } } else { if (DetailsVM.Documents != null) { DetailsVM.Documents.Clear(); } if (SelectedNodeVM.Children == null || SelectedNodeVM.Children.Count() == 0) { var result = GetChildNodes(); if (result != null) { SelectedNodeVM.Children = result; } } } }
private void ExportToExcel() { if (DetailsVM != null) { DetailsVM.ExportToExcel(); } }
// GET: Products/Details/5 public async Task <ActionResult> Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } //Products products = await db.Products.FindAsync(id); //if (products == null) //{ // return HttpNotFound(); //} //return View(products); DetailsVM model = new DetailsVM(); Products prods = await db.Products.FindAsync(id); if (prods == null) { return(HttpNotFound()); } model.Item = prods.Item; model.Brand = prods.Brand; model.Description = prods.Description; model.Qty = prods.Qty; model.Cost = prods.Cost; model.Price = prods.Price; model.Country = prods.Country; model.Provider = prods.Provider; model.Warranty = prods.Warranty; model.DateAd = prods.DateAd; model.DateCr = prods.DateCr; model.DateUp = prods.DateUp; return(View(model)); }
public ActionResult Details(int?id) { if (id == null) { return(HttpNotFound()); } Advertisment advertisment = db.Advertisments.Find(id); if (advertisment == null) { return(HttpNotFound("This advertisments not found")); } DetailsVM vm = new DetailsVM { Advertisment = advertisment, RelatedAds = db.Advertisments.Where(a => a.Model.ID == advertisment.Model.ID && a.ID != advertisment.ID).Take(5).ToList(), ResentNewsVM = new ResentNewsVM { News = db.News.Take(5).ToList() }, }; return(View(vm)); }
public IActionResult Details(int id) { List <ShoppingCart> shoppingCartList = new List <ShoppingCart>(); if (HttpContext.Session.Get <IEnumerable <ShoppingCart> >(WC.SessionCart) != null && HttpContext.Session.Get <IEnumerable <ShoppingCart> >(WC.SessionCart).Count() > 0) { shoppingCartList = HttpContext.Session.Get <List <ShoppingCart> >(WC.SessionCart); } DetailsVM DetailsVM = new DetailsVM() { Product = _prodRepo.FirstOrDefault(u => u.Id == id, includeProperties: "Category,ApplicationType"), ExistsInCart = false }; foreach (var item in shoppingCartList) { if (item.ProductId == id) { DetailsVM.ExistsInCart = true; } } return(View(DetailsVM)); }
public IActionResult Details(int id) { //To see if exists Session name WC.SessionCart="ShoppingCartSession" List <ShoppingCart> shoppingCartList = new List <ShoppingCart>(); if (HttpContext.Session.Get <IEnumerable <ShoppingCart> >(WC.SessionCart) != null && HttpContext.Session.Get <IEnumerable <ShoppingCart> >(WC.SessionCart).Count() > 0) { //If "ShoppingCartSession" has any value, get it shoppingCartList = HttpContext.Session.Get <List <ShoppingCart> >(WC.SessionCart); } DetailsVM DetailsVM = new DetailsVM() { Product = _prodRepo.FirstOrDefault(u => u.Id == id, includeProperties: "Category,ApplicationType"), ExistsInChart = false }; //Check if id in the ShoppingCartSession foreach (var item in shoppingCartList) { if (item.ProductId == id) { DetailsVM.ExistsInChart = true; } } return(View(DetailsVM)); }
public IActionResult Details(int id) { List <ShoppingCart> ShoppingCartList = new List <ShoppingCart>(); if (HttpContext.Session.Get <IEnumerable <ShoppingCart> >(Constant.SessionCart) != null && HttpContext.Session.Get <IEnumerable <ShoppingCart> >(Constant.SessionCart).Count() > 0) { ShoppingCartList = HttpContext.Session.Get <List <ShoppingCart> >(Constant.SessionCart); } DetailsVM detailsVM = new DetailsVM { Product = _db.Products.Include(p => p.Category).FirstOrDefault(p => p.Id == id), ExistsInCart = false }; foreach (var item in ShoppingCartList) { if (item.ProductId == id) { detailsVM.ExistsInCart = true; } } return(View(detailsVM)); }
public IActionResult Details(int id) { List <ShoppingCart> shoppingCartList = new List <ShoppingCart>(); if (HttpContext.Session.Get <IEnumerable <ShoppingCart> >(WebConstants.SessionCart) != null && HttpContext.Session.Get <IEnumerable <ShoppingCart> >(WebConstants.SessionCart).Count() > 0) { shoppingCartList = HttpContext.Session.Get <List <ShoppingCart> >(WebConstants.SessionCart); } DetailsVM DetailsVM = new DetailsVM() { Product = _db.Product.Include(u => u.Category) .Where(u => u.Id == id).FirstOrDefault(), ExistInCart = false }; foreach (var item in shoppingCartList) { if (item.ProductId == id) { DetailsVM.ExistInCart = true; } } return(View(DetailsVM)); }
public ActionResult Details(int id) { OrdersRepository ordersRepo = new OrdersRepository(); Order order = ordersRepo.GetById(id); int loggedUserId = ((User)Session["loggedUser"]).Id; if (order == null) { return(new HttpNotFoundResult("There is no such order!")); } if (order.UserId != loggedUserId && loggedUserId != 1) { return(new HttpUnauthorizedResult("You can't view other users' orders!")); } DetailsVM model = new DetailsVM(); model.OrderId = order.Id; model.OrderDate = order.OrderDate; model.IsApproved = order.IsApproved; model.OrderProducts = new Dictionary <Product, int>(); foreach (OrderItem orderItem in order.OrderItems) { model.OrderProducts.Add(orderItem.Product, orderItem.Quantity); model.TotalPrice += orderItem.UnitPrice * orderItem.Quantity; } return(View(model)); }
public IActionResult Details(int id) { List <ShoppingCart> shoppingCartList = new List <ShoppingCart>(); if (HttpContext.Session.Get <IEnumerable <ShoppingCart> >(ENV.SessionCart) != null && HttpContext.Session.Get <IEnumerable <ShoppingCart> >(ENV.SessionCart).Count() > 0) { shoppingCartList = HttpContext.Session.Get <List <ShoppingCart> >(ENV.SessionCart); } DetailsVM detailsVM = new DetailsVM() { Product = mapper.Map <ProductViewModel>(productService.GetAllProducts("Category") .FirstOrDefault(u => u.Id == id)), InCart = false }; foreach (var item in shoppingCartList) { if (item.ProductId == id) { detailsVM.InCart = true; } } return(View(detailsVM)); }
public ActionResult AddVehicle(DetailsVM addVehicle) { if (addVehicle.Vehicle.Year < 2000 || addVehicle.Vehicle.Year > 2021) { ModelState.AddModelError("Vehicle.Year", "Please enter a year between 2000 and 2021."); } if (addVehicle.Vehicle.MSRP < 0) { ModelState.AddModelError("Vehicle.MSRP", "MSRP must be a positive number."); } if (addVehicle.Vehicle.SalePrice < 0) { ModelState.AddModelError("Vehicle.SalePrice", "SalePrice must be a positive number."); } if (addVehicle.Vehicle.MSRP < addVehicle.Vehicle.SalePrice) { ModelState.AddModelError("Vehicle.MSRP", "SalePrice must be lower than MSRP."); } if (ModelState.IsValid) { addVehicle.Vehicle.Picture = "placeholder.png"; VehicleRepositoryFactory.GetVehicleRepository().Add(addVehicle.Vehicle); return(RedirectToAction("EditVehicle", new { vinNumber = addVehicle.Vehicle.VinNumber })); } else { var viewModel = addVehicle; viewModel.BodyStyles = BodyStyleRepositoryFactory.GetBodyStyleRepository().GetBodyStyles(); viewModel.Colors = ColorRepositoryFactory.GetColorRepository().GetColors(); viewModel.Makes = MakeRepositoryFactory.GetMakeRepository().GetMakes(); viewModel.Models = ModelRepositoryFactory.GetModelRepository().GetModels(); viewModel.Transmission = TransmissionTypeRepositoryFactory.GetTransmissionTypeRepository().GetTransmissions(); return(View(viewModel)); } }
public IActionResult RemoveFromCart(int id, DetailsVM detailsVM) { List <ShoppingCart> previousCartList = new List <ShoppingCart>(); //Before Adding- get the initial Values in the Session if (HttpContext.Session.Get <IEnumerable <ShoppingCart> >(WebConstant.SessionKey) != null && HttpContext.Session.Get <IEnumerable <ShoppingCart> >(WebConstant.SessionKey).Count() > 0) { previousCartList = HttpContext.Session.Get <List <ShoppingCart> >(WebConstant.SessionKey); } List <ShoppingCart> newCartList = new List <ShoppingCart>(); //After getting the all Values in the session, iterate throught the list and check foreach (var item in previousCartList) { if (item.ProductId != id) { newCartList.Add(item); } } //Set the New Session Dictionary with the new Cart List HttpContext.Session.Set <IEnumerable <ShoppingCart> >(WebConstant.SessionKey, newCartList); return(RedirectToAction("Index", "Home")); }
public ActionResult Index(DetailsVM model) { model.ThemeColor = string.IsNullOrEmpty(model.ThemeColor) ? Colors.black.ToString() : model.ThemeColor; var theme = _factory.GetThemeObject(model.ThemeColor); model.ThemeDetails = theme.GetThemeDetails(); return(View(model)); }
public ActionResult Details(int id) { RecipeBL recipe = new RecipeBL(); DetailsVM detailsVM = new DetailsVM(); detailsVM.Recipe = recipe.GetRecipes().Where(m => m.ID == id).Single(); return(View(detailsVM)); }
public ActionResult Purchase(SaleVM sold) { var details = new DetailsVM(); details.Vehicle = VehicleRepositoryFactory.GetVehicleRepository().GetVehicleByVIN(sold.Sale.VinNumber); details.BodyStyles = BodyStyleRepositoryFactory.GetBodyStyleRepository().GetBodyStyles(); details.Colors = ColorRepositoryFactory.GetColorRepository().GetColors(); details.Makes = MakeRepositoryFactory.GetMakeRepository().GetMakes(); details.Models = ModelRepositoryFactory.GetModelRepository().GetModels(); details.Transmission = TransmissionTypeRepositoryFactory.GetTransmissionTypeRepository().GetTransmissions(); sold.Details = details; if (sold.Sale.Phone == null && sold.Sale.Email == null) { ModelState.AddModelError("", "You must enter a phone number or an email address."); } if (sold.Sale.Zipcode.Length > 5) { ModelState.AddModelError("", "Zipcode should only be 5 digits long, please."); } if (sold.Sale.PurchasePrice < ((sold.Details.Vehicle.MSRP * 95) * .01m)) { ModelState.AddModelError("", "Purchase price should not be lower than 95% vehicle MSRP, please recalculate."); } if (sold.Sale.PurchasePrice > sold.Details.Vehicle.MSRP) { ModelState.AddModelError("", "Purchase price should not be greater than MSRP, please recalculate."); } var repo = SaleRepositoryFactory.GetSaleRepository(); if (ModelState.IsValid) { sold.Sale.UserID = User.Identity.GetUserId(); sold.Sale.PurchaseDate = DateTime.Now; } var result = repo.Add(sold.Sale); if (result != null) { var vehicleToUpdate = VehicleRepositoryFactory.GetVehicleRepository().GetVehicleByVIN(sold.Sale.VinNumber); vehicleToUpdate.IsPurchased = true; vehicleToUpdate.IsFeatured = false; VehicleRepositoryFactory.GetVehicleRepository().Edit(vehicleToUpdate); return(View("Index")); } // assign sold.UserID to currently logged in user // assign sold.PurchaseDate to DateTime.Now // if saving the purchase is a success, update vehicle.IsPurchased to true and vehicle.IsFeatured to false; return(View()); }
public ActionResult Details(int id) { var model = new DetailsVM { Coffee = _db.Coffees.Find(id) }; return(View(model)); }
public ActionResult Details(int id) { DetailsVM model = new DetailsVM(); model.specialization = repo.GetById(id); model.Doctors = model.specialization.Doctors.ToList(); return(View(model)); }
public ActionResult Details(int id) { DetailsVM model = new DetailsVM(); model.medicines = repo.GetById(id); model.Patients = model.medicines.Patients.ToList(); return(View(model)); }
public IActionResult Details(int movieId) { //return a list of screenings for a movie Id var screeningsForMovie = _unitOfWork.Screening.GetScreeningsForMovie(movieId); var movie = _unitOfWork.Movie.GetMovieWithDetails(movieId); var VM = new DetailsVM(screeningsForMovie, movie); return(View(VM)); }
public ActionResult AddVehicle() { var viewModel = new DetailsVM(); viewModel.BodyStyles = BodyStyleRepositoryFactory.GetBodyStyleRepository().GetBodyStyles(); viewModel.Colors = ColorRepositoryFactory.GetColorRepository().GetColors(); viewModel.Makes = MakeRepositoryFactory.GetMakeRepository().GetMakes(); viewModel.Models = ModelRepositoryFactory.GetModelRepository().GetModels(); viewModel.Transmission = TransmissionTypeRepositoryFactory.GetTransmissionTypeRepository().GetTransmissions(); return(View(viewModel)); }
public ActionResult details(int id) { DetailsVM model = new DetailsVM { training = db.trainings.Include("result").Include("grade").SingleOrDefault(e => e.id == id), grades = db.grades.ToList(), results = db.results.ToList() }; return(View(model)); }
public ActionResult EditVehicle(string vinNumber) { var viewModel = new DetailsVM(); viewModel.Vehicle = VehicleRepositoryFactory.GetVehicleRepository().GetVehicleByVIN(vinNumber); viewModel.BodyStyles = BodyStyleRepositoryFactory.GetBodyStyleRepository().GetBodyStyles(); viewModel.Colors = ColorRepositoryFactory.GetColorRepository().GetColors(); viewModel.Makes = MakeRepositoryFactory.GetMakeRepository().GetMakes(); viewModel.Models = ModelRepositoryFactory.GetModelRepository().GetModels(); viewModel.Transmission = TransmissionTypeRepositoryFactory.GetTransmissionTypeRepository().GetTransmissions(); return(View(viewModel)); }
// GET: User public ActionResult Index() { if (Session["UserName"] == null) { return(RedirectToAction("Login", "Authentication")); } else { List <User> userList = db.GetUserList(); List <Budget> budgetList = db.GetBudgetList(); List <Expense> expenseList = db.GetExpenseList(); string currentUser = Session["UserId"].ToString(); int uid = Int32.Parse(currentUser); User user = userList.Where(a => a.UserId == uid).Single(); //Wyświetlenie 10 ostatnio dodanych wydatków var expense = expenseList.Where(a => a.UserId == uid).OrderByDescending(a => a.ReleaseDate).Take(10).ToList(); //Ostatnio dodany budżet Budget lastBudget = budgetList.Where(b => b.UserId == uid).OrderByDescending(b => b.BudgetId).FirstOrDefault(); decimal allBudgets = budgetList.Where(b => b.UserId == uid).Sum(b => b.Salary); //Dane do wykresu try { decimal billExpense = expenseList.Where(x => x.Type == Expense.ExpenseType.Rachunek && x.UserId == uid).Sum(x => x.Cost); decimal shoppingExpense = expenseList.Where(x => x.Type == Expense.ExpenseType.Zakupy && x.UserId == uid).Sum(x => x.Cost); decimal departureExpense = expenseList.Where(x => x.Type == Expense.ExpenseType.Wyjścia && x.UserId == uid).Sum(x => x.Cost); var list = Enum.GetValues(typeof(Expense.ExpenseType)).Cast <Expense.ExpenseType>().ToList(); decimal allExpense = billExpense + shoppingExpense + departureExpense; decimal _value = allBudgets - allExpense; ViewBag.Message = _value; var myChart = new Chart(width: 600, height: 500) .AddTitle("Wydatki") .AddSeries( name: "Wydatki", chartType: "column", xValue: new[] { "Rachunki", "Zakupy", "Wyjścia" }, yValues: new[] { billExpense, shoppingExpense, departureExpense }); myChart.Save("~/Content/chart.png"); } catch { } //Przekazanie do viewmodelu DetailsVM detailsVM = new DetailsVM(); detailsVM.user = user; detailsVM.budget = lastBudget; detailsVM.expense = expense; return(View("Index", detailsVM)); } }
// GET: Generic/Softwares/Details/5 public async Task <IActionResult> Details(int?id) { if (id == null) { return(NotFound()); } DetailsVM vm = new DetailsVM(); var software = await _context.Softwares .Include(s => s.AppUser) .Include(s => s.TechArea) .Include(s => s.Tipi) .Include(s => s.Teams) .Include(s => s.ItOwner) .Include(s => s.SoftwareTeams) .Include(s => s.SoftwareBusinessOwnerTeams) .Include(s => s.Purpose) .FirstOrDefaultAsync(m => m.SoftwareId == id); var softwareTeams = _context.SoftwareTeams.Where(st => st.SoftwareId == id).ToList(); List <Team> teams = new List <Team>(); foreach (var st in softwareTeams) { var tempTeam = await _context.Teams.Where(t => t.TeamId == st.TeamId).FirstOrDefaultAsync(); teams.Add(tempTeam); } //var teams = _context.Teams.Where(t => t.SoftwareTeams.FirstOrDefault().SoftwareId == softwareTeams.FirstOrDefault().SoftwareId).ToList(); software.Teams = teams; var softwareBusinessOwnerTeams = _context.SoftwareBusinessOwnerTeams.Where(sbot => sbot.SoftwareId == id).ToList(); List <Team> businessOwnerTeams = new List <Team>(); foreach (var bot in softwareBusinessOwnerTeams) { var tempTeam = await _context.Teams.Where(t => t.TeamId == bot.BusinessOwnerTeamId).FirstOrDefaultAsync(); businessOwnerTeams.Add(tempTeam); } software.BusinessOwnerTeams = businessOwnerTeams; if (software == null) { return(NotFound()); } vm.Software = software; return(View(vm)); }
// GET: Products/Details/5 public async Task <IActionResult> Details(int?id, DetailsVM vm) { if (id == null) { return(NotFound()); } vm.Product = await _context.Products .Include(m => m.ProductSubcategories).ThenInclude(m => m.SubCategory) .AsNoTracking() .SingleOrDefaultAsync(m => m.Id == id); if (vm.Product == null) { return(NotFound()); } vm.RelatedProducts = await _context.Products .Include(m => m.ProductSubcategories) .ThenInclude(m => m.SubCategory) .Where(m => m.Category == vm.Product.Category) .ToListAsync(); //var query = //from post in context.Posts //where tagIds.All(requiredId => post.Tags.Any(tag => tag.TagId == requiredId)) //select post; var subCatList = from item in vm.Product.ProductSubcategories select item.SubCategoryId; vm.RelatedProducts = from item in vm.RelatedProducts where subCatList.Any(requieredId => item.ProductSubcategories.Any(subCatId => subCatId.SubCategoryId == requieredId)) select item; if (vm.RelatedProducts != null) { vm.RelatedProducts = vm.RelatedProducts.Where(m => m.Id != vm.Product.Id); } //foreach (var item in subCatList) //{ // vm.RelatedProducts = from prod in vm.RelatedProducts // where //} return(View(vm)); }
public void DetailsViewResultWithViewModel(int detailId) { // Arrange HomeVM homeVM = new HomeVM() { Products = GetTestProduct(), Categories = GetTestCategory() }; List <ShoppingCart> shoppingCartList = new List <ShoppingCart>(); var mockLogger = new Mock <ILogger <HomeController> >(); var mockCateRepo = new Mock <ICategoryRepository>(); var mockProdRepo = new Mock <IProductRepository>(); var categories = (IEnumerable <Category>)GetTestCategory(); var prod = GetTestProduct().FirstOrDefault(); var cate = GetTestCategory().FirstOrDefault(); DetailsVM detailVM = new DetailsVM() { ExistsInCart = false, Product = prod }; mockCateRepo.Setup(x => x.GetAll(null, null, null, true)).Returns(homeVM.Categories); mockProdRepo.Setup(x => x.GetAll(null, null, "Category,ApplicationType", true)).Returns(homeVM.Products); var controller = new HomeController(mockLogger.Object, mockProdRepo.Object, mockCateRepo.Object); controller.ControllerContext.HttpContext = new DefaultHttpContext(); var session = new MockHttpSession(); Mock <HttpContext> mockHttpContext = new Mock <HttpContext>(); MockHttpSession mockSession = new MockHttpSession(); mockSession["ShoppingCartSession"] = null; mockHttpContext.Setup(s => s.Session).Returns(mockSession); //controller.ControllerContext.HttpContext = (HttpContext)mockHttpContext.Object; controller.ControllerContext.HttpContext.Session = mockSession; //Action var result = controller.Details(detailId); // Assert correct non-null View returned with no Model var viewResult = Assert.IsType <ViewResult>(result); Assert.NotNull(viewResult); Assert.NotNull(viewResult.ViewData.Model); var viewResultValue = Assert.IsAssignableFrom <DetailsVM>(viewResult.ViewData.Model); Assert.IsType <DetailsVM>(viewResult.ViewData.Model); }
public IActionResult Details(int Id) { OrdersRepository repo = new OrdersRepository(); OrderProductsRepository opRepo = new OrderProductsRepository(); Order order = repo.GetById(Id, true); DetailsVM model = new DetailsVM(); model.Order = order; model.OrderProducts = opRepo.GetAll(op => op.OrderId == order.Id, 1, 10, true); return(View(model)); }
public IActionResult <DetailsVM> Details(int id, HttpSession session, HttpResponse response) { User user = AuthenticationManager.GetAuthenticatedUser(session.Id); if (user == null) { this.Redirect(response, "/home/topics"); return(null); } DetailsVM viewModel = this.service.GetDetailsVm(id); return(this.View(viewModel)); }