public async Task <IActionResult> OnPostAsync() { Products = await _context.Products.ToListAsync(); if (Dish == null || string.IsNullOrWhiteSpace(Dish.Title)) { if (ModelState.TryAddModelError("Title", "Необходимо ввести название")) { return(Page()); } } if (ModelState.IsValid) { foreach (var item in ProductsData.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries)) { var parts = item.Split(new[] { ':' }); if (int.TryParse(parts[0], out int id_product) && int.TryParse(parts[1], out int count_product)) { Dish.Bind(_context.Products.Find(id_product), count_product); } } _context.Dishes.Add(Dish); await _context.Flush(); return(RedirectToPage("Dishes")); } return(Page()); }
public PartialViewResult SearchResult(string search) { List <Products> products = ProductsData.GetProductList(search); ViewData["listSize"] = products.Count; return(PartialView(products)); }
// GET: Home public ActionResult Index() { List <Category> lstCategories = new ProductsData().GetAllCategories(); ViewBag.lstCategory = new SelectList(lstCategories, "CategoryID", "CategoryName"); return(View(new ProductsData().GetAllProducts().Take(20).ToList())); }
public void Configure(IApplicationBuilder app, IHostingEnvironment env, EfDbContext context, RoleManager <ApplicationRole> roleManager, UserManager <ApplicationUser> userManager) { if (env.IsDevelopment()) { app.UseExceptionHandler("/Account/Error"); app.UseDeveloperExceptionPage(); app.UseDatabaseErrorPage(); app.UseStaticFiles(); } else { app.UseExceptionHandler("/Account/Error"); app.UseStaticFiles(); app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseCookiePolicy(); app.UseSession(); app.UseAuthentication(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=MainPage}/{id?}"); }); AdminData.Initialize(context, userManager, roleManager).Wait(); ProductsData.Initialize(context).Wait(); }
public static void Initialize(IServiceProvider serviceProvider) { using (var context = new ApplicationDbContext( serviceProvider.GetRequiredService < DbContextOptions <ApplicationDbContext> >())) { if (!context.Users.Any()) { UsersData usersData = new UsersData(); context.AddRange(usersData.users); context.SaveChanges(); } if (!context.Categories.Any()) { CategoriesData category = new CategoriesData(); context.AddRange(category.categories); context.SaveChanges(); } if (!context.Products.Any()) { ProductsData productsData = new ProductsData(); context.AddRange(productsData.products); context.SaveChanges(); } } }
// GET: Products //Main: ViewProducts public ActionResult ViewProducts(int Id, string sessionId, int productId, int quantity) { //send to view; ViewData["sessionId"] = sessionId; ViewData["Id"] = Id; ViewData["productId"] = productId; ViewData["quantity"] = quantity; //To obtain user information at top partial view and send to View PartialViewUserProfile(sessionId); PartialViewCartCount(); //only if there is productId and quantity change then update the cart if (productId != 0 || quantity != 0) { AddtoOrder(sessionId, productId, quantity); CountCartUpdate(sessionId); } //send to View List <Products> products = ProductsData.GetAllProducts(); ViewData["products"] = products; return(View()); }
public void GetProductByIdFail() { ProductsData controller = new ProductsData(); ProductModel result = controller.GetProductBySKU(100); Assert.IsNull(result); }
public void BeforeAllMethods() { products = ProductsData.GetProductData(); driver = new ChromeDriver(); driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10); driver.Manage().Window.Maximize(); // driver.Navigate().GoToUrl("http://atqc-shop.epizy.com/"); }
// GET: Gallery public ActionResult ProductList(string sessionId) { ViewData["productList"] = ProductsData.GetProductList(""); ViewData["sessionId"] = sessionId; return(View()); }
private void Border_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { ProductsData item = (ProductsData)SnacksBox.SelectedItem; Array.Resize(ref productList, productList.Length + 1); productList[productList.Length - 1] = item; this.selectedProductsBox.ItemsSource = productList; }
public static void ProductsValue(this ProductsData data, string Name, string Surname, string Catagory) { ProductsData data1 = new ProductsData { Name = Name, Surname = Surname, Catagory = Catagory }; Index++; data1.Id++; }
public SelectedProductDetails(ProductsData item) { InitializeComponent(); var productsList = ProductsList.LoadProductsInfo(0); ProductsData selectedItem = productsList.Where(t => t.Id == item.Id).Select(t => t).SingleOrDefault(); ProductsData[] products = new ProductsData[] { selectedItem }; this.ProductDetails.ItemsSource = products; }
public ActionResult ViewCart() { List <CartCookie> cartCookies = CookieFile.GetCartCookie(Request.Cookies); List <Cart> cartList = ProductsData.GetProductDetails(cartCookies); ViewData["cartList"] = cartList; ViewData["sessionId"] = "abc123"; return(View()); }
public void MongoConexionCollection() { //Arrange string coleccionMongoDB = "products"; ProductsData data = new ProductsData(); //Act IMongoCollection <ProductoDTO> resultData = data.GetProductDataById(); //Assert Assert.AreEqual(coleccionMongoDB, resultData.CollectionNamespace.CollectionName); }
public HttpResponseMessage Get() { try { List <Products> products = ProductsData.SelectAll().ToList <Products>(); return(Request.CreateResponse(HttpStatusCode.OK, products)); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex)); } }
public override List <ProductoDTO> GetProductById(int palabra) { ProductsData data = new ProductsData(); IMongoCollection <ProductoDTO> resultData = data.GetProductDataById(); listResultDB = (from r in resultData.AsQueryable() where r.IdProductoDTO == palabra select new ProductoDTO { IdObjetoDTO = r.IdObjetoDTO, IdProductoDTO = r.IdProductoDTO, MarcaProductoDTO = r.MarcaProductoDTO, DescripcionProductoDTO = r.DescripcionProductoDTO, FotoProductoDTO = r.FotoProductoDTO, ValorProductoDTO = r.ValorProductoDTO }).ToList(); return(listResultDB); }
public void RemoveProduct() { ProductsData controller = new ProductsData(); List <WarehouseModel> warehouseList = new List <WarehouseModel>(); warehouseList.Add(new WarehouseModel("SP", 5, "WEB")); warehouseList.Add(new WarehouseModel("SP", 5, "WEB")); controller.Add(new ProductModel(6, "teste", new InventoryModel(warehouseList))); controller.RemoveProduct(6); ProductModel result = controller.GetProductBySKU(6); }
private ProductsData TranslateProductEntityToProduct(Product productEntity) { ProductsData p = new ProductsData() { Discontinued = productEntity.Discontinued, ProductID = productEntity.ProductID, ProductName = productEntity.ProductName, QuantityPerUnit = productEntity.QuantityPerUnit, UnitPrice = (decimal)productEntity.UnitPrice }; return(p); }
public HttpResponseMessage Post(Products product) { try { ProductsData.Add(product); HttpResponseMessage message = Request.CreateResponse(HttpStatusCode.Created, product); message.Headers.Location = new Uri(Request.RequestUri + product.ProductId.ToString()); return(message); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }
public async Task <IActionResult> OnPostAsync() { Products = await _context.Products.ToListAsync(); await _context.Attach(Dish).Collection(x => x.ProductDish).LoadAsync(); if (Dish == null || string.IsNullOrWhiteSpace(Dish.Title)) { if (ModelState.TryAddModelError("Title", "Необходимо ввести название")) { return(Page()); } } if (!ModelState.IsValid) { return(Page()); } Dish.ProductDish.Clear(); _context.Update(Dish); await _context.Flush(); foreach (var item in ProductsData.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries)) { var parts = item.Split(new[] { ':' }); if (int.TryParse(parts[0], out int id_product) && int.TryParse(parts[1], out int count_product)) { Dish.Bind(_context.Products.Find(id_product), count_product); } } try { _context.Update(Dish); await _context.Flush(); } catch (DbUpdateConcurrencyException) { if (!_context.Dishes.Any(e => e.Id == Dish.Id)) { return(NotFound()); } else { throw; } } return(RedirectToPage("DishView", Dish.Id)); }
public DetailedProduct(ProductsData item) { InitializeComponent(); var productsList = ProductsList.LoadProductsInfo(0); ProductsData selectedItem = productsList.Where(t => t.Id == item.Id).Select(t => t).SingleOrDefault(); var uri = new Uri(selectedItem.ImageData.ToString()); ProductDetailImage.Source = new BitmapImage(uri); ProductDesc.Content = selectedItem.Title; ProductPrice.Content = selectedItem.Price; FirstRibbonText.Content = "1 pc of " + selectedItem.Title; SecondRibbonText.Content = selectedItem.Price; this.SnacksBox.ItemsSource = ProductsList.LoadSnacks(); this.CloseButton.Style = this.Resources["ToggleButtonWindowClose"] as Style; }
public void GetProducts() { ProductsData controller = new ProductsData(); List <WarehouseModel> warehouseList = new List <WarehouseModel>(); warehouseList.Add(new WarehouseModel("SP", 5, "WEB")); warehouseList.Add(new WarehouseModel("SP", 5, "WEB")); controller.Add(new ProductModel(1, "teste", new InventoryModel(warehouseList))); controller.Add(new ProductModel(2, "outro", new InventoryModel(warehouseList))); List <ProductModel> result = controller.GetProducts(); Assert.IsNotNull(result); Assert.AreEqual(2, result.Count); }
/// <summary> /// Добавление товара /// </summary> public void AddNewProduct(ProductsData product) { adminPanel.OpenAdminPage(); adminPanel .EntryUserName("admin") .EntryUserPass("admin") .SubmitLogin(); addProduct.OpenCatalog(); addProduct.AddNewProductButton.Click(); addProduct.Status.Click(); addProduct.NameInput.SendKeys(product.Name); addProduct.CodeInput.SendKeys(product.Code); addProduct.Categories.Click(); addProduct.ProductGroups.Click(); addProduct.QuantityGeneralTab(product.Quantity); addProduct.QuantityUnitGeneralTab(); addProduct.DeliveryStatusGeneralTab(); addProduct.SoldOutStatusGeneralTab(); addProduct.UploadImages.SendKeys(product.ImagePath); addProduct.DateValidFrom(product.DateFrom); addProduct.DateValidTo(product.DateTo); addProduct.InformationTab.Click(); addProduct.ManufacturerInformationTab(); addProduct.KeywordsInput.SendKeys(product.Keywords); addProduct.ShortDescriptionInput.SendKeys(product.ShortDescription); addProduct.DescriptionInput.SendKeys(product.Description); addProduct.HeadTitleInput.SendKeys(product.HeadTitle); addProduct.MetaDescriptionInput.SendKeys(product.MetaDescription); addProduct.PricesTab.Click(); addProduct.PurchasePricePricesTab(product.PurchasePrice); addProduct.PurchaseCurrencyPricesTab(); string usd = addProduct.SetPriceUSDTab(); string eur = addProduct.SetPriceEURTab(); addProduct.CampaignsLink.Click(); addProduct.CampaignsStartDate(product.DateFrom); addProduct.CampaignsEndDate(product.DateTo); addProduct.CampaignsPercentage(); addProduct.CampaignsUSD(usd); addProduct.CampaignsEUR(eur); addProduct.Save(); }
public ActionResult NewProduct(ProductsData productModel) { var config = new MapperConfiguration(cfg => cfg.CreateMap <ProductsData, ProductsDatas>()); var mapper = new Mapper(config); var prod = mapper.Map <ProductsDatas>(productModel); ProductsResp product = _product.SetProductsList(prod); if (product.Status) { ModelState.AddModelError("", product.StatusMsg); return(RedirectToAction("Index", "Product")); } ModelState.AddModelError("", product.StatusMsg); return(View()); }
public void AddProduct() { ProductsData controller = new ProductsData(); List <WarehouseModel> warehouseList = new List <WarehouseModel>(); warehouseList.Add(new WarehouseModel("SP", 5, "WEB")); warehouseList.Add(new WarehouseModel("SP", 5, "WEB")); ProductModel prod = new ProductModel(3, "teste", new InventoryModel(warehouseList)); controller.Add(prod); ProductModel result = controller.GetProductBySKU(3); Assert.IsNotNull(result); Assert.AreEqual(prod, result); }
public override List <ProductoDTO> GetProductByName(string palabra) { ProductsData data = new ProductsData(); IMongoCollection <BsonDocument> products = data.GetProductDataByName(); FilterDefinitionBuilder <BsonDocument> builder = Builders <BsonDocument> .Filter; FilterDefinition <BsonDocument> filter = @"{ $or: [{ ""brand"" : {$in: [/$palabra$/] }},{ ""description"" : {$in: [/$palabra$/] }}] }".Replace("$palabra$", palabra); List <BsonDocument> resultFiltros = products.Find(filter).ToList(); foreach (BsonDocument item in resultFiltros) { ProductoDTO myObj = BsonSerializer.Deserialize <ProductoDTO>(item); listResultDB.Add(myObj); } return(listResultDB); }
public ActionResult ActivationCode(int NewOrderId, int Id, string sessionId) //enter activation code in each product { //define the variable needed first string activationCode = ""; List <Order> OrderSummary = (List <Order>)Session[sessionId + "_Orders"]; foreach (Order order in OrderSummary) { for (int i = 0; i < order.Quantity; i++) { activationCode = Add.getCode(); string message = ProductsData.EnterActivationCode(NewOrderId, order.ProductId, activationCode); } } return(RedirectToAction("ViewPurchaseHistory", "Checkout", new { NewOrderId = NewOrderId, Id = Id, sessionId = sessionId })); }
private void Border_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { ProductsData item = (ProductsData)ProductsBox.SelectedItem; MainWindow win = (MainWindow)Window.GetWindow(this); win.MainWindowWithLeftPanel.Visibility = Visibility.Hidden; win.MainWindowWithOutLeftPanel.Visibility = Visibility.Visible; var productsList = ProductsList.LoadProductsInfo(0); ProductsData selectedItem = productsList.Where(t => t.Id == item.Id).Select(t => t).SingleOrDefault(); var uri = new Uri(selectedItem.ImageData.ToString()); win.ProductDetailImage.Source = new BitmapImage(uri); win.ProductDesc.Content = selectedItem.Title; win.ProductPrice.Content = selectedItem.Price; win.FirstRibbonText.Content = "1 pc of " + selectedItem.Title; win.SecondRibbonText.Content = selectedItem.Price; win.SnacksBox.ItemsSource = ProductsList.LoadSnacks(); }
public HttpResponseMessage Get(int id) { try { Products product = ProductsData.Select_Record(new Products() { ProductId = id }); if (product == null) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Product with given Id does not exist!")); } return(Request.CreateResponse(HttpStatusCode.OK, product)); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex)); } }
public ProductsData GetProductID(int id) { ProductsData product = null; using (var context = new NorthwindEntities1()) { var productEntity = (from p in context.Products where p.ProductID == id select p).FirstOrDefault(); if (productEntity != null) { product = TranslateProductEntityToProduct(productEntity); } else { throw new Exception(string.Format("Invalid productID {0}", id)); } } return(product); }