Esempio n. 1
0
        private void btnAddCrudShop_Click(object sender, EventArgs e)
        {
            ProductDAL productDAL = new ProductDAL();
            UserDAL    userDAL    = new UserDAL();

            if (cmbCategoryCrudShop.Text != "" && txbCountCrudShop.Text != "" && txbPriceCrudShop.Text != "")
            {
                Product product = new Product()
                {
                    Name       = this.txbNameCrudShop.Text,
                    CategoryId = Convert.ToInt32(this.cmbCategoryCrudShop.Text.Split('-')[0]),
                    Count      = Convert.ToInt32(this.txbCountCrudShop.Text),
                    Price      = Convert.ToDouble(this.txbPriceCrudShop.Text),
                    UserId     = CurrentUser.Id,
                    Status     = (int)ProductStatusEnum.Active,
                };
                bool isValid = ValidationOperation <Product> .ValidateOperation(product);

                if (CurrentUser.Type == 2)
                {
                    product.UserId = userDAL.GetByFilter(x => x.Email == this.cmbUserCrudProducts.Text.Split('-')[0]).Id;
                }
                if (isValid)
                {
                    productDAL.Add(product);
                    MessageBox.Show("Successfully Added!");
                    productDAL.GetGridData(dgvShop);
                }
            }
            else
            {
                MessageBox.Show("The field is required");
            }
        }
Esempio n. 2
0
        public JsonResult PostProduct(ProductVM productVM)
        {
            string  message;
            Product obj = new Product()
            {
                Name         = productVM.Name,
                Price        = productVM.Price,
                Decription   = productVM.Decription,
                Image        = "",
                BrandFK      = productVM.BrandFK,
                CatFK        = productVM.CatFK,
                SubCatFK     = productVM.SubCatFK,
                CreatedBy    = 1,
                CreationDate = DateTime.Now,
                IsBestSeller = productVM.IsBestSeller
            };

            ViewBag.FormName = "PostProduct";
            return(Json(
                       new
            {
                done = productDAL.Add(obj, out message),
                message,
                add = true
            },
                       JsonRequestBehavior.AllowGet));
        }
Esempio n. 3
0
        public ActionResult ProductProcess(Product entity, HttpPostedFileBase file, string isNew)
        {
            if (file != null && file.ContentLength > 0 && file.ContentLength < 10485760)
            {
                ImageUpload imageUpload = new ImageUpload();

                string imagePath = imageUpload.ImageResize(file, 673, 483);

                if (isNew != "true")
                {
                    string filePath = Server.MapPath(entity.PictureUrl);
                    if (System.IO.File.Exists(filePath))
                    {
                        System.IO.File.Delete(filePath);
                    }
                }

                entity.PictureUrl = imagePath;
            }

            if (isNew == "true")
            {
                int addResult = proMng.Add(entity);
            }
            else
            {
                bool updateResult = proMng.Update(entity);
            }

            return(RedirectToAction("UrunIslemleri", "Product"));
        }
Esempio n. 4
0
        static private void AddProduct()
        {
            ProductDTO product = new ProductDTO();

            product.UserId = currentUser.Id;

            Console.Write("Please enter Name of product: ");
            product.ProductName = Console.ReadLine().ToString();

            Console.Write("Please enter Price:");
            product.Price = Convert.ToDecimal(Console.ReadLine().ToString());

            productDAL.Add(product);
        }
 public void Add(ProductDTO DTO)
 {
     DAL.Add(DTO);
 }