public async Task <IActionResult> PutProducts(int id, ProductsVM pvm) { if (id != pvm.Product_ID) { return(BadRequest()); } Products p = new Products(); p.Product_ID = Convert.ToInt32(pvm.Product_ID); p.Product_Name = pvm.Product_Name; p.Details = pvm.Details; p.Product_Source = pvm.Product_Source; db.Entry(p).State = EntityState.Modified; await db.SaveChangesAsync(); try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProductsExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public ActionResult ProductDetails(string name) { //Deklarisati VM i DTO ProductsVM model; ProductsDTO dto; //Inicijalizovati ProductsId int id = 0; using (ShoppingCartDB db = new ShoppingCartDB()) { //Proveriti da li postoji product if (!db.Products.Any(x => x.Slug.Equals(name))) { RedirectToAction("Index", "Shop"); } //inicijalizovati DTO dto = db.Products.Where(x => x.Slug == name).FirstOrDefault(); //Uzeti id id = dto.Id; //inicijalizovati model model = new ProductsVM(dto); } //Pronaci slike //uzeti sve slike iz glaerije model.GalleryImages = Directory.EnumerateFiles(Server.MapPath("~/Images/Uploads/Products/" + id + "/Gallery/Thumbs")).Select(x => Path.GetFileName(x)); //vratiti View sa modelom return(View("ProductDetails", model)); }
public ActionResult ProductDetails(string name) { ProductsVM model; ProductDTO dto; int id = 0; using (Db db = new Db()) { if (!db.Products.Any(x => x.Slug.Equals(name))) { return(RedirectToAction("Index", "Shop")); } dto = db.Products.Where(x => x.Slug == name).FirstOrDefault(); id = dto.Id; model = new ProductsVM(dto); model.GalleryImages = Directory .EnumerateFiles(Server.MapPath("~/Images/Uploads/Products/" + id + "/Gallery/Thumbs")) .Select(fn => Path.GetFileName(fn)); } return(View("ProductDetails", model)); }
public IActionResult GetProductsByCategoryId(int id) { ProductsVM model = new ProductsVM(); model.products = _productRepo.GetProductsByCategoryId(id); return(View(model)); }
public ActionResult EditProduct(int id) { //Declare productVm ProductsVM model; using (db DB = new db()) { //Get the product ProductsDTO dto = DB.Products.Find(id); //confirm product exists if (dto == null) { return(Content("That product does not exist.")); } //init model model = new ProductsVM(dto); //make a select list model.Categories = new SelectList(DB.Categories.ToList(), "Id", "Name"); //get gallery images model.GalleryImages = Directory.EnumerateFiles(Server.MapPath("~/Images/Uploads/Products/" + id + "/Gallery/Thumbs")) .Select(fn => Path.GetFileName(fn)); } //return view with model return(View(model)); }
public ActionResult EditProduct(int id) { //deklarisanje productVM-a ProductsVM model; using (ShoppingCartDB db = new ShoppingCartDB()) { //pronaci product ProductsDTO dto = db.Products.Find(id); //proveriti da li postoji if (dto == null) { return(Content("This item doesn't exists")); } //inicijalizovati model model = new ProductsVM(dto); //napraviti select listu model.Categories = new SelectList(db.Categories.ToList(), "Id", "Name"); //uzeti sve slike iz glaerije model.GalleryImages = Directory.EnumerateFiles(Server.MapPath("~/Images/Uploads/Products/" + id + "/Gallery/Thumbs")).Select(x => Path.GetFileName(x)); } //vratit view sa modelom return(View(model)); }
public ActionResult ProductDetails(string name) { //Declare the VM and DTO ProductsVM model; ProductsDTO dto; //Init product id int id = 0; using (db DB = new db()) { //Check if product exists if (!DB.Products.Any(x => x.Slug.Equals(name))) { return(RedirectToAction("Index", "Shop")); } //Inti productDTO dto = DB.Products.Where(x => x.Slug == name).FirstOrDefault(); //Get id id = dto.ID; //Init model model = new ProductsVM(dto); } //Get gallery images model.GalleryImages = Directory.EnumerateFiles(Server.MapPath("~/Images/Uploads/Products/" + id + "/Gallery/Thumbs")) .Select(fn => Path.GetFileName(fn)); return(View("ProductDetails", model)); }
public ActionResult CatFilter(string CatID) { ProductList prc = new ProductList(); ProductsVM prcVM = new ProductsVM(); int kat1, kat2; string[] karakter = new string[2]; karakter = CatID.Split('-'); kat1 = Convert.ToInt32(karakter[0]); kat2 = Convert.ToInt32(karakter[1]); //if (kat1 == 1) //{ // prcVM.ErkekList = prc.KatIkiUrunListele(kat1, kat2); //} //else if (kat1 == 2) //{ // prcVM.KadınList = prc.KatIkiUrunListele(kat1, kat2); //} //else //{ // prcVM.CocukList = prc.KatIkiUrunListele(kat1, kat2); //} prcVM.KategoriBirListe = prc.KatBirListe(); prcVM.KategoriIkiListe = prc.KatIkiListe(); prcVM.UrunListe = prc.KatIkiUrunListele(kat1, kat2); prcVM.KatBirAd = db.ProductCatOne.FirstOrDefault(x => x.ProductCatOneID == kat1).CategoryName; return(View(prcVM)); }
public ActionResult ProductInfo(ProductsVM vm) { if (Session["Tracker"] == null) { return(RedirectToAction("ApplicantInfo", "Applicant")); } var tracker = (Guid)Session["Tracker"]; if (ModelState.IsValid) { var applicant = _context.Applicants.FirstOrDefault(x => x.ApplicantTracker == tracker); var existingProducts = applicant.Products.FirstOrDefault(); if (existingProducts != null) { Mapper.Map(vm, existingProducts); _context.Entry(existingProducts).State = EntityState.Modified; } else { var newProducts = Mapper.Map <Products>(vm); applicant.Products.Add(newProducts); } _context.SaveChanges(); return(RedirectToAction("Final", "Home")); } return(View()); }
public ActionResult ProductInfo(ProductsVM productsVM) { if (Session["Tracker"] == null) { return(RedirectToAction("ApplicantInfo", "Applicant")); } var tracker = (Guid)Session["Tracker"]; if (ModelState.IsValid) { var applicant = _applicantService.GetApplicantsByTraker(tracker); var existingProducts = applicant.Products.FirstOrDefault(); if (existingProducts != null) { var productsDto = Mapper.Map(productsVM, existingProducts); _productsService.Update(productsDto); } else { var newProducts = Mapper.Map <ProductsDto>(productsVM); applicant.Products.Add(newProducts); } return(RedirectToAction("Final", "Home")); } return(View()); }
public IActionResult Create(ProductsVM model) { if (ModelState.IsValid) { string uniqueFileName = null; if (model.Photo != null) { string uploadFolder = Path.Combine(_hostingEnv.WebRootPath, "img"); uniqueFileName = Guid.NewGuid() + "_" + model.Photo.FileName; string filePath = Path.Combine(uploadFolder, uniqueFileName); model.Photo.CopyTo(new FileStream(filePath, FileMode.Create)); } Product newProduct = new Product { ProductName = model.ProductName, ProductImage = uniqueFileName, ProductArtNumber = model.ProductArtNumber, ProductDescription = model.ProductDescription, CategoryId = model.CategoryId }; ViewData["CategoryId"] = new SelectList(_context.Categories, "CartegoryId", "Name", model.CategoryId); _context.Products.Add(newProduct); _context.SaveChanges(); return(RedirectToAction("Index")); } return(View(model)); }
public ActionResult EditProduct(int id) { //Declare productVM ProductsVM model; using (Db db = new Db()) { //Get the product ProductDTO dto = db.Products.Find(id); //Make sure it exists if (dto == null) { return(Content("That product does not exsist.")); } //init the model model = new ProductsVM(dto); //Make a select list model.Categories = new SelectList(db.Categories.ToList(), "Id", "Name"); //Get all gallery images model.GalleryImages = Directory.EnumerateFiles(Server.MapPath("~/Images/Uploads/Products/" + id + "/Gallery/Thumbs")) .Select(fn => Path.GetFileName(fn)); } //Return the view with the model return(View(model)); }
public IActionResult GetAll() { ProductsVM model = new ProductsVM(); model.products = _productRepo.GetAll(); return(View(model)); }
public ProductsVM GetProductdetails(string sku) { var client = new HttpClient(); string productCode = sku; var requestUri = $"http://tfs-test-api.fsdomain.local/api/v1/productlookupapi/get-product-details?sku={productCode}"; var response = client.GetAsync(requestUri) .Result; var json = response.Content.ReadAsStringAsync().Result; var results = JsonConvert.DeserializeObject <ProductsVM>(json); if (results != null) { return(results); } var model = new ProductsVM() { proddesc = "No Product", department = "No Level 3", group = "No Level 4", subgroup = "No Level 5" }; return(model); }
public void CreateTest() { ProductsVM vm = _controller.Wtm.CreateVM <ProductsVM>(); Products v = new Products(); v.ProductUnitID = AddProductUnit(); v.ProductTypesID = AddProductTypes(); v.ProMax = 57; v.ProMin = 92; v.ProdName = "db4u"; v.ProWorkShop = "o6d"; v.PhotoId = AddFileAttachment(); v.ProInPrice = 64; v.ProPrice = 79; v.ProDesc = "ven0"; vm.Entity = v; var rv = _controller.Add(vm); Assert.IsInstanceOfType(rv, typeof(OkObjectResult)); using (var context = new DataContext(_seed, DBTypeEnum.Memory)) { var data = context.Set <Products>().Find(v.ID); Assert.AreEqual(data.ProMax, 57); Assert.AreEqual(data.ProMin, 92); Assert.AreEqual(data.ProdName, "db4u"); Assert.AreEqual(data.ProWorkShop, "o6d"); Assert.AreEqual(data.ProInPrice, 64); Assert.AreEqual(data.ProPrice, 79); Assert.AreEqual(data.ProDesc, "ven0"); Assert.AreEqual(data.CreateBy, "user"); Assert.IsTrue(DateTime.Now.Subtract(data.CreateTime.Value).Seconds < 10); } }
public async Task <ActionResult> Index() { ProductsVM obj = new ProductsVM(); obj.Products = await _productService.GetProducts(); TempData["Products"] = obj; return(View(obj)); }
public IActionResult Create() { var productVM = new ProductsVM { // Products = new Product{}, Categories = _categoryRepository.GetAll().ToList() }; return(View(productVM)); }
public ActionResult Dogs()//called when clicking the "dogs" label on page Layout { ProductsDal dal = new ProductsDal(); ProductsVM productsV = new ProductsVM(); productsV.products_list = (from y in dal.products where y.type.Equals("Dogs") select y).ToList <Products>(); return(View("../Home/ShowHomePage", productsV));// returns Home page with list of products from Dogs type }
public ProductsController(ApplicationDbContext db, HostingEnvironment he) { _db = db; _he = he; productsVM = new ProductsVM() { ProductTypes = _db.productTypes.ToList(), specialTags = _db.specialTags.ToList(), products = new Models.Products() }; }
public AccessoriesController() { _vm = new ProductsVM(); _reposProduct = new ProductDAO(); _repositoryPartner = new PartnershipDAO(); IRepositryBase <Fly_Navigation> repositryNav = new NavigationDao(); List <Fly_Navigation> listNav = repositryNav.getAllItems().ToList(); ViewData[StaticVariable.Navigation] = listNav; }
public ActionResult Category(int?id) { var model = new ProductsVM { Products = unitOfWork.Products.Find(x => !id.HasValue || x.CategoryId == id.Value), SelectedCategory = id.HasValue ? unitOfWork.Categories.FirstOrDefault(x => x.Id == id) : null }; model.SearchString = id.HasValue ? $"Category \"{model.SelectedCategory?.Name}\"" : null; return(View("Products", model)); }
public ActionResult search() { string product_name = Request.Form["product_name"]; ProductsDal dal = new ProductsDal(); ProductsVM products = new ProductsVM(); products.products_list = (from y in dal.products where y.product_name.Contains(product_name) || y.type.Equals(product_name) select y).ToList <Products>(); return(View("../Home/ShowHomePage", products)); }
public ProductsController(ApplicationDbContext db, HostingEnvironment hostingEnvironment) { _db = db; _hostingEnvironment = hostingEnvironment; ProductsVM = new ProductsVM() { ProductTypes = _db.ProductTypes.ToList(), SpecialTags = _db.SpecialTags.ToList(), Products = new Models.Products() }; }
public ActionResult ShowProducts(ProductsVM pvm) { string custId = SessionFacade.LOGGEDIN; Console.WriteLine(custId); if (custId == null) { return(RedirectToAction("Login", "Auth")); } pvm.cList = _bus.getCategory(); pvm.pList = _bus.getProductsbyCategory(pvm.catselected); return(View(pvm)); }
// GET: Products public ActionResult Index() { ProductsVM prvm = new ProductsVM(); ProductList prc = new ProductList(); prvm.ErkekList = prc.KatBirUrunListele(1); prvm.KadınList = prc.KatBirUrunListele(2); prvm.CocukList = prc.KatBirUrunListele(3); prvm.KategoriBirListe = prc.KatBirListe(); prvm.KategoriIkiListe = prc.KatIkiListe(); return(View(prvm)); }
public ActionResult AddProducts() { //Inicijalizuj model ProductsVM model = new ProductsVM(); //Dodaj selectovanu listu kategorija modelu using (ShoppingCartDB db = new ShoppingCartDB()) { model.Categories = new SelectList(db.Categories.ToList(), "Id", "Name"); } //Vratiti view sa modelom return(View(model)); }
public ProductsController(ApplicationDbContext db, IHostingEnvironment hostingEnvironment) { _db = db; _hostingEnvironment = hostingEnvironment; // Инициализируем привязанное свойство в конструкторе значениями ID сопутствующих таблиц ProductsVm = new ProductsVM() { ProductTypes = _db.ProductTypeses.ToList(), SpecialTags = _db.SpecialTagses.ToList(), Products = new Products() }; }
public ActionResult AddProduct() { //Init model ProductsVM model = new ProductsVM(); //Add select list of categories to model using (db DB = new db()) { model.Categories = new SelectList(DB.Categories.ToList(), "ID", "Name"); } //return view with model return(View(model)); }
// GET: Men public ActionResult Index(ProductCategory category) { ProductsVM viewModel = new ProductsVM() { Category = category, Products = new ProductManager().GetProductByCategory(category, Gender.Male), CurrencyCode = Services.CookieService.GetCurrency(Request.Cookies) }; viewModel.Products = viewModel.Products.Where(p => p.Category == category).ToList(); return(View(viewModel)); }
public ActionResult AddProduct() { //init mode ProductsVM model = new ProductsVM(); //add select list of categories to model using (Db db = new Db()) { model.Categories = new SelectList(db.Categories.ToList(), "Id", "Name"); } //return view with model return(View(model)); }