Beispiel #1
0
        public async Task <IActionResult> PutShoeModel(int id, ShoeModel shoeModel)
        {
            if (id != shoeModel.IdShoe)
            {
                return(BadRequest());
            }

            _context.Entry(shoeModel).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ShoeModelExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Beispiel #2
0
        public async Task <ActionResult <ShoeModel> > PostShoeModel(ShoeModel shoeModel)
        {
            _context.Shoe.Add(shoeModel);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetShoeModel", new { id = shoeModel.IdShoe }, shoeModel));
        }
Beispiel #3
0
 public ActionResult ShoeUpdate(ShoeModel shoe)
 {
     if (ModelState.IsValid)
     {
         _service.UpdateShoe(shoe);
         return(RedirectToAction("ShoeIndex"));
     }
     return(View());
 }
Beispiel #4
0
 public ActionResult ShoeCreate(ShoeModel shoe)
 {
     ViewBag.UserId = User.Identity.GetUserId();
     if (ModelState.IsValid)
     {
         _service.CreateShoe(shoe);
         return(RedirectToAction("ShoeIndex"));
     }
     return(View());
 }
Beispiel #5
0
        public async Task <IActionResult> Edit(int id, [Bind("IdShoe,Name,Date,Img,Price,Sizes,Colors,NumberSeri,Shoelate,Version,Materials,Sales,Type,Pro,Description,Status")] ShoeModel shoeModel, IFormFile imageUpload)
        {
            if (id != shoeModel.IdShoe)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(shoeModel);
                    if (imageUpload != null)
                    {
                        var path = Path.Combine(
                            Directory.GetCurrentDirectory(), "wwwroot/admin/assets/images/image", shoeModel.Img);
                        System.IO.File.Delete(path);

                        path = Path.Combine(
                            Directory.GetCurrentDirectory(), "wwwroot/admin/assets/images/image",
                            shoeModel.IdShoe + "." + imageUpload.FileName.Split(".")[imageUpload.FileName.Split(".").Length - 1]);

                        using (var stream = new FileStream(path, FileMode.Create))
                        {
                            await imageUpload.CopyToAsync(stream);
                        }

                        shoeModel.Img = shoeModel.IdShoe + "." + imageUpload.FileName.Split(".")[imageUpload.FileName.Split(".").Length - 1];
                        _context.Update(shoeModel);
                        await _context.SaveChangesAsync();
                    }
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ShoeModelExists(shoeModel.IdShoe))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["Colors"]    = new SelectList(_context.Color, "IdColor", "Name", shoeModel.Colors);
            ViewData["Materials"] = new SelectList(_context.MaterialModel, "IdMaterial", "Name", shoeModel.Materials);
            ViewData["Pro"]       = new SelectList(_context.Producer, "IdPro", "Name", shoeModel.Pro);
            ViewData["Sales"]     = new SelectList(_context.Sale, "Id", "Name", shoeModel.Sales);
            ViewData["Sizes"]     = new SelectList(_context.Size, "IdSize", "NumSize", shoeModel.Sizes);
            ViewData["Type"]      = new SelectList(_context.TypeShoe, "IdType", "Name", shoeModel.Type);
            return(View(shoeModel));
        }
Beispiel #6
0
 private Shoe ToShoe(ShoeModel shoe)
 {
     return(new Shoe
     {
         Id = shoe.Id,
         Color = shoe.Color,
         Brand = shoe.Brand,
         Style = shoe.Style,
         OwnerId = shoe.OwnerId,
         IsPair = shoe.IsPair
     });
 }
Beispiel #7
0
        public void UpdateShoe(ShoeModel shoe)
        {
            var shoeRecord = _repository.GetShoe(shoe.Id);

            shoeRecord.Color   = shoe.Color;
            shoeRecord.Brand   = shoe.Brand;
            shoeRecord.Style   = shoe.Style;
            shoeRecord.OwnerId = shoe.OwnerId;
            shoeRecord.IsPair  = shoe.IsPair;

            _repository.UpdateShoe(shoeRecord);
        }
Beispiel #8
0
 public ShoeModel AddNewShoeModel(ShoeModel _shoeModel)
 {
     try
     {
         using (ShoeContext = new ShoeContext(database))
         {
             _shoeModel = ShoeContext.ShoeModels.Add(_shoeModel);
             ShoeContext.SaveChanges();
             return(_shoeModel);
         }
     }
     catch { return(null); }
 }
        private void insertpage()
        {
            //retrieve all the product form database
            ShoeModel          shoeModel = new ShoeModel();
            List <BootProduct> product   = shoeModel.RetrieveAllProduct();

            //the product must exist in the database
            if (product != null)
            {
                //create an image and zoom in
                foreach (BootProduct products in product)
                {
                    Panel       bootsPanel = new Panel();
                    ImageButton zoomIn     = new ImageButton();
                    Label       NameLabel  = new Label();
                    Label       PriceLabel = new Label();

                    //set child control properties
                    zoomIn.ImageUrl    = "~/img/productimage/" + products.Image;
                    zoomIn.CssClass    = "BootsImage";
                    zoomIn.PostBackUrl = "~/Brands.aspx?id=" + products.ID;

                    NameLabel.Text     = products.ShoeName;
                    NameLabel.CssClass = "ShoeName";

                    PriceLabel.Text     = "BND " + products.Price;
                    PriceLabel.CssClass = "ShoePrice";

                    //add the child control
                    bootsPanel.Controls.Add(zoomIn);
                    bootsPanel.Controls.Add(new Literal {
                        Text = "<br/>"
                    });
                    bootsPanel.Controls.Add(NameLabel);
                    bootsPanel.Controls.Add(new Literal {
                        Text = "<br/>"
                    });
                    bootsPanel.Controls.Add(PriceLabel);

                    //add the dynamic panels
                    BootsPanel.Controls.Add(bootsPanel);
                }
            }
            else
            {
                //no products
                BootsPanel.Controls.Add(new Literal {
                    Text = "There is no products!"
                });
            }
        }
Beispiel #10
0
        public ShoeModel GetAndAddShoeModel(ShoeModel _shoeModel)
        {
            try
            {
                var shoeModel = GetShoeModel(_shoeModel.Model_Number, _shoeModel.Model_Name);
                if (shoeModel != null)
                {
                    return(shoeModel);
                }

                return(AddNewShoeModel(_shoeModel));
            }
            catch { return(null); }
        }
Beispiel #11
0
        /// <summary>
        /// Temp function
        /// </summary>
        /// <param name="cellValue"></param>
        /// <param name="Select_ModelName"></param>
        /// <param name="cuttingType"></param>
        /// <returns></returns>
        private List <ShoeModel> Add_SameModel(object cellValue, string Select_ModelName, string cuttingType)
        {
            if (cellValue != null)
            {
                List <ShoeModel> modelList = new List <ShoeModel>();

                try
                {
                    string   s      = cellValue.ToString().Trim();
                    string[] models = s.Split(new string[] { "," }, StringSplitOptions.None);
                    foreach (string m in models)
                    {
                        string model_num = m.Trim();
                        if (model_num != "")
                        {
                            ShoeModel checkM = new ShoeModel
                            {
                                Model_Number = model_num,
                                Model_Name   = Select_ModelName
                            };

                            var currentM = unblock.ComponentQuery.GetAndAddShoeModel(checkM);

                            if (currentM != null)
                            {
                                modelList.Add(currentM);
                            }
                        }
                    }

                    List <ShoeModel> AddModels = new List <ShoeModel>();
                    foreach (ShoeModel currentModel in modelList)
                    {
                        var modelComponent = unblock.ComponentQuery.GetModelComponent(currentModel.Id, cuttingType);

                        if (modelComponent == null)
                        {
                            AddModels.Add(currentModel);
                        }
                    }
                    return(AddModels);
                }
                catch { return(null); }
            }
            else
            {
                return(null);
            }
        }
Beispiel #12
0
        private void Fillpage(int id)
        {
            //get selected details  from database
            ShoeModel   shoeModel = new ShoeModel();
            BootProduct product   = shoeModel.GetProducts(id);

            //Fill the text
            Desctxt.Text  = product.Description;
            Nametxt.Text  = product.ShoeName;
            Pricetxt.Text = product.Price.ToString();

            //set the value of dropdown
            ImageDropDown.SelectedValue = product.Image;
            TypeDropDown.SelectedValue  = product.ShoeType.ToString();
        }
Beispiel #13
0
        public override ScrapePageResponse ScrapeWebpage(ScrapePageRequest request)
        {
            ShoeModel tmpShoe;

            ShoeModel[] tmpArray = null;

            ScrapePageResponse response = new ScrapePageResponse {
                Success = true, Message = ""
            };

            try
            {
                HtmlDocument       webpage = _webscraper.Load(request.Website[1]);
                HtmlNodeCollection nodes   = webpage.DocumentNode.SelectNodes("//div[contains(@class, 'rt-holder')]");
                _shoeCount           = nodes.Count;
                response.ScrapeCount = _shoeCount;

                if (_shoeCount != 0)
                {
                    tmpArray = new ShoeModel[_shoeCount];

                    for (int i = 0; i < _shoeCount; ++i)
                    {
                        tmpShoe             = new ShoeModel();
                        tmpShoe.ID          = 0;
                        tmpShoe.WebsiteName = request.Website[0];
                        tmpShoe.WebsiteURL  = request.Website[1];
                        tmpShoe.ModelName   = WebScraper.CleanHTMLString(nodes[i].SelectNodes("//h3 [contains(@class, 'entry-title')]")[i].InnerText);
                        tmpShoe.Description = WebScraper.CleanHTMLString(nodes[i].SelectNodes("//h3 [contains(@class, 'entry-title')]")[i].InnerText);
                        //tmpShoe.Description = WebScraper.CleanHTMLString(nodes[i].SelectNodes("//div[contains(@class, 'post-meta-user')]//i")[i].InnerText);
                        tmpShoe.ImageURI    = nodes[i].SelectNodes("//div[contains(@class, 'rt-holder')]//img")[i].GetAttributeValue("src", "");
                        tmpShoe.ImageBinary = WebScraper.LoadImageBinary(tmpShoe.ImageURI);
                        tmpArray[i]         = tmpShoe;
                    }
                    request.ShoeList.AddRange(tmpArray);
                }
            }
            catch (Exception ex)
            {
                _shoeCount = 0;

                response.Success = false;
                response.Message = ex.Message;
            }

            return(response);
        }
Beispiel #14
0
        protected void Submitbtn_Click(object sender, EventArgs e)
        {
            ShoeModel   bootProduct = new ShoeModel();
            BootProduct product     = CreateProduct();

            //checck if there is an id on the websitename
            if (!string.IsNullOrWhiteSpace(Request.QueryString["id"]))
            {
                //there is an id
                int id = Convert.ToInt32(Request.QueryString["id"]);
                ResultLabel.Text = bootProduct.UpdateProduct(id, product);
            }
            else
            {
                //no id
                ResultLabel.Text = bootProduct.InsertProduct(product);
            }
        }
Beispiel #15
0
        private void insertPage()
        {
            //take selected product
            if (!String.IsNullOrWhiteSpace(Request.QueryString["id"]))
            {
                int         id        = Convert.ToInt32(Request.QueryString["id"]);
                ShoeModel   shoeModel = new ShoeModel();
                BootProduct products  = shoeModel.GetProducts(id);

                //insert the data
                BootsPrice.Text       = "Price per pair: <br/>$ " + products.Price;
                BootsTitle.Text       = products.ShoeName;
                BootsDescription.Text = products.Description;
                BootsID.Text          = id.ToString();
                BootsImage.ImageUrl   = "~/img/productimage/" + products.Image;

                //fill the dropdown list
                int[] amount = Enumerable.Range(1, 20).ToArray();
                AmountDropDown.DataSource           = amount;
                AmountDropDown.AppendDataBoundItems = true;
                AmountDropDown.DataBind();
            }
        }
Beispiel #16
0
        public async Task <IActionResult> Create([Bind("IdShoe,Name,Date,Img,Price,Sizes,Colors,NumberSeri,Shoelate,Version,Materials,Sales,Type,Pro,Description,Status")] ShoeModel shoeModel, IFormFile imageUpload)
        {
            if (ModelState.IsValid)
            {
                shoeModel.Img = "avatar.png";
                _context.Add(shoeModel);
                await _context.SaveChangesAsync();

                /* _context.Add(shoeModel);
                 * await _context.SaveChangesAsync();
                 * return RedirectToAction(nameof(Index));*/


                var path = Path.Combine(
                    Directory.GetCurrentDirectory(), "wwwroot/admin/assets/images/image",
                    shoeModel.IdShoe + "." + imageUpload.FileName.Split(".")[imageUpload.FileName.Split(".").Length - 1]);
                using (var stream = new FileStream(path, FileMode.Create))
                {
                    await imageUpload.CopyToAsync(stream);
                }
                shoeModel.Img = shoeModel.IdShoe + "." + imageUpload.FileName.Split(".")[imageUpload.FileName.Split(".").Length - 1];



                _context.Update(shoeModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["Colors"]    = new SelectList(_context.Color, "IdColor", "Name", shoeModel.Colors);
            ViewData["Materials"] = new SelectList(_context.MaterialModel, "IdMaterial", "Name", shoeModel.Materials);
            ViewData["Pro"]       = new SelectList(_context.Producer, "IdPro", "Name", shoeModel.Pro);
            ViewData["Sales"]     = new SelectList(_context.Sale, "Id", "Id", shoeModel.Sales);
            ViewData["Sizes"]     = new SelectList(_context.Size, "IdSize", "IdSize", shoeModel.Sizes);
            ViewData["Type"]      = new SelectList(_context.TypeShoe, "IdType", "Name", shoeModel.Type);
            return(View(shoeModel));
        }
        private void CreateShoppingTable(List <BootCart> boughtList, out double subTotal)
        {
            subTotal = new Double();
            ShoeModel model = new ShoeModel();

            foreach (BootCart cart in boughtList)
            {
                BootProduct product = model.GetProducts(cart.ProductID);

                //create the image button
                ImageButton ImageBtn = new ImageButton
                {
                    ImageUrl    = String.Format("~/img/productimage/{0}", product.Image),
                    PostBackUrl = String.Format("~/Brands.aspx?id={0}", product.ID)
                };

                //Create Delete button
                LinkButton DeleteLink = new LinkButton
                {
                    PostBackUrl = string.Format("~/ShopCart.aspx?ProductId={0}", cart.ID),
                    Text        = "Delete Item",
                    ID          = "delete" + cart.ID
                };

                //Add on click
                DeleteLink.Click += Delete_Item;

                //Create the dropdownlist on the quantity
                int[]        amount         = Enumerable.Range(1, 20).ToArray();
                DropDownList AmountDropDown = new DropDownList
                {
                    DataSource           = amount,
                    AppendDataBoundItems = true,
                    AutoPostBack         = true,
                    ID = cart.ID.ToString()
                };

                AmountDropDown.DataBind();
                AmountDropDown.SelectedValue         = cart.Price.ToString();
                AmountDropDown.SelectedIndexChanged += AmountDropDown_SelectedIndexChanged;

                //create table with 2 rows
                Table table = new Table {
                    CssClass = "cartTable"
                };
                TableRow a = new TableRow();
                TableRow b = new TableRow();

                //create 6 cells
                TableCell a11 = new TableCell {
                    RowSpan = 2, Width = 50
                };
                TableCell a12 = new TableCell
                {
                    Text = string.Format("<h4>{0}<h4><br/>{1}<br/>InStock",
                                         product.ShoeName, "Item No: " + product.ID),
                    HorizontalAlign = HorizontalAlign.Left,
                    Width           = 350
                };
                TableCell a13 = new TableCell {
                    Text = "Unit Price<hr/>"
                };
                TableCell a14 = new TableCell {
                    Text = "Quantity<hr/>"
                };
                TableCell a15 = new TableCell {
                    Text = "Total Pairs<hr/>"
                };
                TableCell a16 = new TableCell {
                };

                //create another 6 cells

                TableCell b1 = new TableCell {
                };
                TableCell b2 = new TableCell {
                    Text = "BND " + product.Price
                };
                TableCell b3 = new TableCell {
                };
                TableCell b4 = new TableCell {
                    Text = "BND " + Math.Round((cart.Price * (double)product.Price), 2)
                };
                TableCell b5 = new TableCell {
                };
                TableCell b6 = new TableCell {
                };

                //set the controls
                a11.Controls.Add(ImageBtn);
                a16.Controls.Add(DeleteLink);
                b3.Controls.Add(AmountDropDown);

                //add cells to row
                a.Cells.Add(a11);
                a.Cells.Add(a12);
                a.Cells.Add(a13);
                a.Cells.Add(a14);
                a.Cells.Add(a15);
                a.Cells.Add(a16);

                b.Cells.Add(b1);
                b.Cells.Add(b2);
                b.Cells.Add(b3);
                b.Cells.Add(b4);
                b.Cells.Add(b5);
                b.Cells.Add(b6);

                //add rows to table
                table.Rows.Add(a);
                table.Rows.Add(b);

                //add table to shopping cart panel
                ShopCartPanel.Controls.Add(table);

                //add the total price
                subTotal += (cart.Price * (double)product.Price);

                //add user current shopping cart
                Session[User.Identity.GetUserId()] = boughtList;
            }
        }
Beispiel #18
0
 public void CreateShoe(ShoeModel shoe)
 {
     _repository.CreateShoe(ToShoe(shoe));
 }
Beispiel #19
0
        // handle update component to database
        private void Handle_CuttingComponents(DataTable table, bool auto_cut)
        {
            string Select_ModelName = "";
            int    initial_row      = 4;

            string cutting_type = "auto";

            if (!auto_cut)
            {
                cutting_type        = "beam";
                initial_row         = 2;
                unblock.TotalModel2 = 0;
            }
            else
            {
                unblock.TotalModel1 = 0;
            }

            BeginInvoke(new MethodInvoker(() =>
            {
                lb_Exeption2.Text    = "...";
                progressBar2.Value   = 0;
                progressBar2.Maximum = table.Rows.Count - initial_row;
            }));

            for (int i = initial_row; i < table.Rows.Count; i++)
            {
                BeginInvoke(new MethodInvoker(() =>
                {
                    progressBar2.Value++;
                    lb_TotalModel1.Text = unblock.TotalModel1.ToString();
                    lb_TotalModel2.Text = unblock.TotalModel2.ToString();
                }));

                var    row                  = table.Rows[i];
                object model_name           = row[1]; // model name column
                object model                = row[2]; // model column
                object first_component_cell = row[5]; // first column of parts
                object samemodel            = row[4]; // first column of parts
                object articleCell          = row[5];

                if (model_name != null)
                {
                    if (model_name.ToString() != "")
                    {
                        Select_ModelName = model_name.ToString();
                    }
                }

                if (model != null && model.ToString() != "")
                {
                    ShoeModel Select_Model = new ShoeModel
                    {
                        Model_Number = model.ToString().Trim().ToUpper(),
                        Model_Name   = Select_ModelName.Trim().ToUpper()
                    };


                    Select_Model = unblock.ComponentQuery.GetAndAddShoeModel(Select_Model);

                    if (Select_Model == null)
                    {
                        continue;
                    }

                    if (auto_cut)
                    {
                        unblock.TotalModel1++;
                    }
                    else
                    {
                        unblock.TotalModel2++;
                    }

                    if (first_component_cell != null && first_component_cell.ToString() != "")
                    {
                        List <ShoeComponent> Select_Components = new List <ShoeComponent>();
                        for (int c = 0; c < 30; c++)
                        {
                            if (row[c + 5] != null)
                            {
                                string cellvalue = row[c + 5].ToString().Trim();

                                // break out from the for loop
                                if (cellvalue == "" ||
                                    cellvalue == " " ||
                                    cellvalue == "  " ||
                                    cellvalue.IndexOf("  ") > -1)
                                {
                                    break;
                                }

                                ShoeComponent shoeComponent = unblock.ComponentQuery.GetAndAddShoeComponent(cellvalue.Trim());
                                if (shoeComponent != null)
                                {
                                    Select_Components.Add(shoeComponent);
                                }
                            }
                        }

                        CuttingType ctype = unblock.ComponentQuery.GetCuttingType(cutting_type);

                        if (Select_Components.Count > 0)
                        {
                            foreach (ShoeComponent c in Select_Components)
                            {
                                unblock.ComponentQuery.AddNewModelComponent(Select_Model.Id, c.Id, ctype.id);
                            }
                        }
                    }
                }
                BeginInvoke(new MethodInvoker(() =>
                {
                    lb_Exeption2.Text = $"{progressBar2.Value * 100 / progressBar2.Maximum} %";
                }));
            }
        }