public int Create(ProductAddModel product)
        {
            var http = (HttpWebRequest)WebRequest.Create(new Uri(_url));

            http.Accept      = "application/json";
            http.ContentType = "application/json";
            http.Method      = "POST";

            string       parsedContent = JsonConvert.SerializeObject(product);
            UTF8Encoding encoding      = new UTF8Encoding();

            Byte[] bytes = encoding.GetBytes(parsedContent);

            Stream newStream = http.GetRequestStream();

            newStream.Write(bytes, 0, bytes.Length);
            newStream.Close();

            var response = http.GetResponse();

            var stream  = response.GetResponseStream();
            var sr      = new StreamReader(stream);
            var content = sr.ReadToEnd();

            //Debug.WriteLine(content.ToString());

            return(0);
        }
예제 #2
0
        public async Task <bool> AddProductAsync(ProductAddModel model)
        {
            MultipartFormDataContent formData = new MultipartFormDataContent();

            if (model.Image != null)
            {
                var stream = new MemoryStream();
                await model.Image.CopyToAsync(stream);

                var bytes = stream.ToArray();

                ByteArrayContent arrayContent = new ByteArrayContent(bytes);

                arrayContent.Headers.ContentType = new MediaTypeHeaderValue(model.Image.ContentType);

                formData.Add(arrayContent, nameof(ProductAddModel.Image), model.Image.FileName);
            }

            formData.Add(new StringContent(model.Name), nameof(ProductAddModel.Name));
            formData.Add(new StringContent(model.Description), nameof(ProductAddModel.Description));

            _httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", _accessor.HttpContext.Session.GetString("token"));

            var responseMessage = await _httpClient.PostAsync("", formData);

            if (responseMessage.IsSuccessStatusCode)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public IActionResult Add()
        {
            //LİSTELERİ OLUŞTUR, FOREACH İLE İÇLERİNİ DOLDUR
            List <SelectListItem> SelectCategory = new List <SelectListItem> {
                new SelectListItem(text: "Kategori Seçiniz", value: "")
            };
            List <SelectListItem> SelectCompany = new List <SelectListItem> {
                new SelectListItem(text: "Firma Seçiniz", value: "")
            };

            foreach (var item in ICategoryServices.CategoryListItem())
            {
                SelectCategory.Add(new SelectListItem {
                    Text = item.CategoryName, Value = item.ID.ToString()
                });
            }


            foreach (var item2 in ICompanyServices.CompanyListItem())
            {
                SelectCompany.Add(new SelectListItem {
                    Text = item2.CompanyName, Value = item2.ID.ToString()
                });
            }

            //LİSTELER TAMAM, MODELİ OLUŞTURUP İLGİLİ ALANLARA SETLE VİEW'A YOLLA

            ProductAddModel productAddModel = new ProductAddModel
            {
                CategorySelectList = SelectCategory,
                CompanySelecList   = SelectCompany
            };

            return(View(productAddModel));
        }
        public ActionResult Update(ProductAddModel model)
        {
            if (ModelValidate(model.Product).IsValid)
            {
                _uow.GetRepo <Product>().Update(model.Product);
                try
                {
                    if (_uow.Commit() > 0)
                    {
                        TempData["Msg"] = "Başarıyla güncellenmiştir.";
                        ModelState.Clear();
                    }
                }
                catch (Exception ex)
                {
                    TempData["Msg"] = "Bir hata oluştu";
                    _log.ProgramLogging(ex.Message);
                    _uow.Commit();
                }
            }
            else
            {
                _collect.CollectError <ProductValidator, Product>(model.Product);
            }

            return(View());
        }
예제 #5
0
        public ActionResult AddProduct(int id = 0, string lang = "tr")
        {
            var languages = LanguageManager.GetLanguages();
            var list      = new SelectList(languages, "Culture", "Language", lang);

            ViewBag.LanguageList = list;

            if (RouteData.Values["id"] != null)
            {
                ViewBag.SaveResult = true;
                ViewBag.ProductId  = id;
            }
            else
            {
                ViewBag.SaveResult = false;
            }

            web.Areas.Admin.Models.VMProductGroupModel grouplist = new Models.VMProductGroupModel();
            grouplist.ProductGroup = ProductManager.GetProductGroupList(lang);
            ProductAddModel model = new ProductAddModel();

            model.VMProductGroupModel = grouplist;

            //      ViewBag.Groups = grouplist;
            return(View(model));
        }
        public ActionResult AddProduct(string message)
        {
            string role = CurrentUser.Role;

            if (role != Convert.ToString((byte)UserType.Admin))
            {
                return(RedirectToAction("index", "home"));
            }

            var productAddModel = new ProductAddModel();

            if (message != null)
            {
                productAddModel.ProductAddedCheck = true;
            }
            var categories = _categoryService.GetAllCategory().Where(x => x.CategoryType == (byte)CategoryType.Category);

            productAddModel.Categories.Add(new SelectListItem {
                Text = "Seçiniz", Value = "0", Selected = true
            });
            foreach (var item in categories)
            {
                productAddModel.Categories.Add(new SelectListItem {
                    Text = item.CategoryName, Value = item.ID.ToString()
                });
            }

            return(View(productAddModel));
        }
예제 #7
0
        public ActionResult EditProduct(int id = 0)
        {
            web.Areas.Admin.Models.VMProductGroupModel grouplist = new Models.VMProductGroupModel();
            grouplist.ProductGroup = ProductManager.GetProductGroupList("tr");
            ProductAddModel model = new ProductAddModel();

            model.VMProductGroupModel = grouplist;

            if (RouteData.Values["id"] != null)
            {
                ViewBag.SaveResult = true;
                ViewBag.ProductId  = id;

                Product prt = ProductManager.GetProductById(id);
                ViewBag.CategoryId = prt.ProductGroupId;
                model.Product      = prt;
                ViewBag.lang       = prt.Language;
            }
            else
            {
                ViewBag.SaveResult = false;
            }

            var photos = PhotoManager.GetList(11, id);

            ViewBag.Photos            = photos;
            model.VMProductGroupModel = grouplist;
            //      ViewBag.Groups = grouplist;
            return(View(model));
        }
예제 #8
0
 public Product(ProductAddModel p)
 {
     Name        = p.Name;
     Stock       = p.Stock;
     Price       = p.Price;
     ImageUrl    = p.ImageUrl;
     Description = p.Description;
 }
        public ActionResult AddProduct(ProductAddModel model)
        {
            string role = CurrentUser.Role;

            if (role != Convert.ToString((byte)UserType.Admin))
            {
                return(RedirectToAction("index", "home"));
            }
            #region treeinsert
            var    category                  = _categoryService.GetCategoryByCategoryId(model.CategoryId);//tree insert product
            string productGroupName          = _categoryService.GetCategoryByCategoryId(model.ProductGroupId).CategoryName;
            PrepareCategoryHash categoryHash = new PrepareCategoryHash();
            categoryHash.CreateHashTableAndProductTree();
            var categoryTable = categoryHash.GetCategoryTable;
            var productGroupTreeForCategory  = (ProductGroupTree)categoryTable[category.CategoryName];
            ProductGroupTreeNode node        = productGroupTreeForCategory.GetProductTreeNodeByProductGroupName(productGroupTreeForCategory.GetRoot(), productGroupName);
            ProductItemModel     productItem = new ProductItemModel();
            productItem.BrandName          = model.BrandName;
            productItem.ModelName          = model.ModelName;
            productItem.ProductCost        = model.Cost;
            productItem.ProductDescription = model.ProductDescription;
            productItem.ProductPrice       = model.Price;
            productItem.Status             = true;
            productItem.ProductNumber      = model.ProductNumber;
            productItem.ProductName        = model.ProductName;
            node.ProductBase.Products.Add(productItem);

            #endregion
            #region databaseinsert
            string fileNameDt = "";
            if (Request.Files.Count > 0)//resim upload
            {
                var file = Request.Files[0];

                if (file != null && file.ContentLength > 0)
                {
                    var fileName = Path.GetFileName(file.FileName);
                    fileNameDt = fileName;
                    var path = Path.Combine(Server.MapPath("~/ProductImages/"), fileName);
                    file.SaveAs(path);
                }
            }
            Product product = new Product();//database adding
            product.BrandName          = model.BrandName;
            product.CategoryId         = model.ProductGroupId;
            product.ModelName          = model.ModelName;
            product.ProductCost        = model.Cost;
            product.ProductDescription = model.ProductDescription;
            product.ProductName        = model.ProductName;
            product.ProductNumber      = model.ProductNumber;
            product.ProductPrice       = model.Price;
            product.ProductImagePath   = fileNameDt;
            product.Status             = true;
            _productservice.AddProduct(product);
            #endregion
            return(RedirectToAction("AddProduct", new { message = "success" }));
        }
예제 #10
0
        public ProductListModel Insert(ProductAddModel productModel)
        {
            //var varbinaryData = Convert.FromBase64String(productModel.Image);
            var product = _mapper.Map <Product>(productModel);

            base.Validate(product, Activator.CreateInstance <ProductValidator>());

            if (product.Invalid)
            {
                return(default);
예제 #11
0
        public async Task <IActionResult> Post([FromBody] ProductAddModel product)
        {
            var entity = this.mapper.Map <Product>(product);

            await this.unitOfWork.Products.InsertAsync(entity);

            await this.unitOfWork.SaveAsync();

            return(CreatedAtRoute(routeName: "Product", routeValues: new { id = entity.Id.ToString() }, value: entity.Id));
        }
예제 #12
0
        public async Task <HttpResponseMessage> CreateAsync(ProductAddModel model)
        {
            var product = await Services.Management.CreateProductAsync(model);

            var response = Request.CreateResponse(HttpStatusCode.Created);
            var uri      = Url.Link(RetrieveProductRoute, new { id = product.Id });

            response.Headers.Location = new Uri(uri);
            return(response);
        }
        public async Task <IActionResult> AddProduct(ProductAddModel model)
        {
            var response = await _product.AddProductAsync(model, User.Identity.Name);

            if (response.IsSuccess)
            {
                return(Json(response));
            }

            return(UnprocessableEntity(response.Message));
        }
예제 #14
0
 public async Task <IActionResult> AddProduct(ProductAddModel model)
 {
     if (await _productService.AddProductAsync(model))
     {
         return(RedirectToAction("Index", "Product"));
     }
     else
     {
         ModelState.AddModelError("", "Resim yükleme hatası! Lütfen JPG veya PNG türünde yükleme yapınız. Resmin boyutu 1MB'ı geçemez");
         return(View(model));
     }
 }
예제 #15
0
        public async Task <IActionResult> AddProduct()
        {
            var categoryListApi = RestService.For <ICategoryApi>(_configuration.GetSection("MyAddress").Value);
            var categoryList    = await categoryListApi.GetAll();

            var model = new ProductAddModel
            {
                Product    = new Product(),
                Categories = categoryList
            };

            return(View(model));
        }
예제 #16
0
        public async Task <IHttpActionResult> AddNewData(ProductAddModel productModel)
        {
            try
            {
                await _productService.AddNewProduct(productModel);

                return(Ok());
            }
            catch (Exception e)
            {
                return(Content(HttpStatusCode.InternalServerError, e.Message));
            }
        }
        public Dictionary <string, string> Create(ProductAddModel product)
        {
            var http = (HttpWebRequest)WebRequest.Create(new Uri(_url));

            // тип відправлення
            http.Accept = "application/json";
            // тип прийому
            http.ContentType = "application/json";
            // тип запиту на сервер
            http.Method = "POST";

            // посилаємо запит
            string       parsedContent = JsonConvert.SerializeObject(product);
            UTF8Encoding encoding      = new UTF8Encoding();

            Byte[] bytes = encoding.GetBytes(parsedContent);

            Stream newStream = http.GetRequestStream();

            newStream.Write(bytes, 0, bytes.Length);
            newStream.Close();

            // отримаємо відповідь
            try
            {
                var response = http.GetResponse();
            }
            catch (WebException ex)
            {
                // Помилки при валідації даних
                using (var stream = ex.Response.GetResponseStream())
                {
                    if (ex.Response != null)
                    {
                        using (var errorResponse = (HttpWebResponse)ex.Response)
                        {
                            using (var reader = new StreamReader(errorResponse.GetResponseStream()))
                            {
                                string errorsString = reader.ReadToEnd();
                                var    errorsObj    = JsonConvert.DeserializeObject <Dictionary <string, string> >(errorsString);

                                return(errorsObj);
                            }
                        }
                    }
                }
            }

            return(null);
        }
        public static Product ConvertToEntity(this ProductAddModel addModel)
        {
            Product product = new Product
            {
                ProductTypeId       = addModel.ProductTypeId,
                Price               = addModel.Price,
                Model               = addModel.Model,
                RepresentativeImage = addModel.RepresentativeImage
            };

            product.ChangeAttributes(addModel.Attributes);
            product.ChangeImages(addModel.Images);
            return(product);
        }
        public IActionResult Update(ProductAddModel productAddModel)
        {
            if (!ModelState.IsValid)
            {
                List <SelectListItem> SelectCategory = new List <SelectListItem> {
                    new SelectListItem {
                        Text = "Kategori", Value = ""
                    }
                };
                List <SelectListItem> SelectCompany = new List <SelectListItem> {
                    new SelectListItem {
                        Text = "Firma", Value = ""
                    }
                };

                foreach (var category in ICategoryServices.CategoryListItem())
                {
                    SelectCategory.Add(new SelectListItem {
                        Text = category.CategoryName, Value = category.ID.ToString()
                    });
                }

                foreach (var company in ICompanyServices.CompanyListItem())
                {
                    SelectCompany.Add(new SelectListItem {
                        Text = company.CompanyName, Value = company.ID.ToString()
                    });
                }

                productAddModel.CategorySelectList = SelectCategory;
                productAddModel.CompanySelecList   = SelectCompany;
                return(View(productAddModel));   //MODELDEKİ VALİDASYONA UYMUYORSA VİEW'I GERİ DÖNDÜR.
            }

            else
            {
                Product product = new Product   //GELEN MODEL İLE BİR CUSTOMER OLUŞTUR
                {
                    ProductID       = productAddModel.ID,
                    ProductName     = productAddModel.Product,
                    CategoryID      = productAddModel.CategoryID,
                    CompanyID       = productAddModel.CompanyID,
                    Price           = productAddModel.Price,
                    QuantityPerUnit = productAddModel.QuantityPerUnit
                };

                IProductService.Update(product);   //BUNU UPDATE METHOTUNA YOLLA.
                return(RedirectToAction("Index")); //SAYFAYI YENİLE
            }
        }
예제 #20
0
        public async Task <ActionResult> AddNew(ProductAddModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            model.UserId = Session["userId"].ToString();
            var response = await MvcApplication.httpClient.PostAsJsonAsync("api/Product/AddNewData", model);

            if (response.IsSuccessStatusCode)
            {
                return(RedirectToAction("Index", "Home"));
            }

            return(View(model));
        }
        public IActionResult Add(ProductAddModel productAddModel)
        {
            if (!ModelState.IsValid)
            {
                List <SelectListItem> SelectCategory = new List <SelectListItem> {
                    new SelectListItem(text: "Kategori Seçiniz", value: "")
                };
                List <SelectListItem> SelectCompany = new List <SelectListItem> {
                    new SelectListItem(text: "Firma Seçiniz", value: "")
                };
                foreach (var item in ICategoryServices.CategoryListItem())
                {
                    SelectCategory.Add(new SelectListItem {
                        Text = item.CategoryName, Value = item.ID.ToString()
                    });
                }


                foreach (var item2 in ICompanyServices.CompanyListItem())
                {
                    SelectCompany.Add(new SelectListItem {
                        Text = item2.CompanyName, Value = item2.ID.ToString()
                    });
                }

                productAddModel.CategorySelectList = SelectCategory;
                productAddModel.CompanySelecList   = SelectCompany;

                return(View(productAddModel));
            }

            else
            {
                Product product = new Product
                {
                    ProductName     = productAddModel.Product,
                    CategoryID      = productAddModel.CategoryID,
                    CompanyID       = productAddModel.CompanyID,
                    Price           = productAddModel.Price,
                    QuantityPerUnit = productAddModel.QuantityPerUnit
                };

                IProductService.Add(product);
                return(RedirectToAction("Index"));
            }
        }
        public IActionResult Update(int id)
        {
            Product getProduct = IProductService.GetProduct(id);

            //LİSTELERİ OLUŞTUR
            List <SelectListItem> SelectCategory = new List <SelectListItem> {
                new SelectListItem {
                    Text = "Kategori", Value = ""
                }
            };
            List <SelectListItem> SelectCompany = new List <SelectListItem> {
                new SelectListItem {
                    Text = "Firma", Value = ""
                }
            };

            foreach (var category in ICategoryServices.CategoryListItem())
            {
                SelectCategory.Add(new SelectListItem {
                    Text = category.CategoryName, Value = category.ID.ToString()
                });
            }

            foreach (var company in ICompanyServices.CompanyListItem())
            {
                SelectCompany.Add(new SelectListItem {
                    Text = company.CompanyName, Value = company.ID.ToString()
                });
            }


            ProductAddModel productAddModel = new ProductAddModel
            {
                ID                 = id,
                Product            = getProduct.ProductName,
                CategoryID         = getProduct.CategoryID,
                CompanyID          = getProduct.CompanyID,
                Price              = getProduct.Price,
                QuantityPerUnit    = getProduct.QuantityPerUnit,
                CategorySelectList = SelectCategory,
                CompanySelecList   = SelectCompany
            };

            return(View(productAddModel));   //BU BİLGİLERİ ALANLARA YAZMAK İÇİN VİEW'A YOLLA
        }
예제 #23
0
        public ActionResult AddProduct()
        {
            ViewBag.PageInfo = "ÜRÜN EKLE";
            ProductAddModel     addModel = new ProductAddModel();
            HttpResponseMessage result;

            result = WebApiRequestOperation.WebApiRequestOperationMethodForUser(SystemConstannts.WebApiDomainAddress, "api/Category/GetCategories", null);

            if (result.StatusCode == HttpStatusCode.OK)
            {
                string resultString = result.Content.ReadAsStringAsync().Result;
                if (resultString != "{\"Categories\":null}")
                {
                    GetCategoryListResponse getCategory = Newtonsoft.Json.JsonConvert.DeserializeObject <GetCategoryListResponse>(resultString);
                    if (getCategory.Code == 1)
                    {
                        addModel.Categories = getCategory.Categories;
                    }
                    else
                    {
                        addModel.Categories = null;
                    }
                }
            }

            result = WebApiRequestOperation.WebApiRequestOperationMethodForUser(SystemConstannts.WebApiDomainAddress, "api/Brand/GetBrands", null);
            if (result.StatusCode == HttpStatusCode.OK)
            {
                string resultString = result.Content.ReadAsStringAsync().Result;
                if (resultString != "{\"Brands\":null}")
                {
                    GetBrandListResponse getBrand = Newtonsoft.Json.JsonConvert.DeserializeObject <GetBrandListResponse>(resultString);
                    if (getBrand.Code == 1)
                    {
                        addModel.Brands = getBrand.Brands;
                    }
                    else
                    {
                        addModel.Brands = null;
                    }
                }
            }
            addModel.Product = null;
            return(View(addModel));
        }
예제 #24
0
        public async Task <IResponse <Product> > AddAsync(ProductAddModel model)
        {
            var product = new Product().CopyFrom(model);

            if (model.TagIds != null && model.TagIds.Any())
            {
                product.ProductTags = new List <ProductTag>(model.TagIds.Select(x => new ProductTag {
                    TagId = x
                }));
            }
            if (model.Files != null && model.Files.Count != 0)
            {
                var getAssets = await _productAssetService.SaveRange(model);

                if (!getAssets.IsSuccessful)
                {
                    return new Response <Product> {
                               Message = getAssets.Message
                    }
                }
                ;
                product.ProductAssets = getAssets.Result;
                await _productRepo.AddAsync(product);

                var add = await _appUow.ElkSaveChangesAsync();

                if (!add.IsSuccessful)
                {
                    _productAssetService.DeleteRange(getAssets.Result);
                }
                return(new Response <Product> {
                    Result = product, IsSuccessful = add.IsSuccessful, Message = add.Message
                });
            }
            else
            {
                await _productRepo.AddAsync(product);

                var add = await _appUow.ElkSaveChangesAsync();

                return(new Response <Product> {
                    Result = product, IsSuccessful = add.IsSuccessful, Message = add.Message
                });
            }
        }
예제 #25
0
        public async Task <IResponse <IList <ProductAsset> > > SaveRange(ProductAddModel model)
        {
            try
            {
                var items = new List <ProductAsset>();
                var pdt   = PersianDateTime.Now;
                var dir   = $"/Files/{model.StoreId}/{pdt.Year}/{pdt.Month}";
                if (!FileOperation.CreateDirectory(model.Root + dir))
                {
                    return new Response <IList <ProductAsset> > {
                               Message = ServiceMessage.SaveFileFailed
                    }
                }
                ;
                foreach (var file in model.Files)
                {
                    var relativePath = $"{dir}/{Guid.NewGuid().ToString().Replace("-", "_")}{Path.GetExtension(file.FileName)}";

                    var physicalPath = (model.Root + relativePath).Replace("/", "\\");
                    items.Add(new ProductAsset
                    {
                        Name       = file.FileName,
                        Extention  = Path.GetExtension(file.FileName),
                        FileType   = FileOperation.GetFileType(file.FileName),
                        FileUrl    = model.BaseDomain + relativePath,
                        CdnFileUrl = physicalPath
                    });
                    using (var stream = File.Create(physicalPath))
                        await file.CopyToAsync(stream);
                }

                return(new Response <IList <ProductAsset> > {
                    IsSuccessful = true, Result = items
                });
            }
            catch (Exception e)
            {
                FileLoger.Error(e);
                return(new Response <IList <ProductAsset> >
                {
                    Message = ServiceMessage.SaveFileFailed
                });
            }
        }
        public async Task <ProductModel> CreateProductAsync(ProductAddModel model)
        {
            if (await _repositories.Products.AnyAsync(o => o.Name == model.Name))
            {
                throw new BusinessException(string.Format("A product already exists with name: {0}", model.Name));
            }

            var product = new Product(model.Name)
            {
                Description       = model.Description,
                QuantityAvailable = model.QuantityAvailable
            };

            _repositories.Products.Insert(product);

            await _repositories.SaveChangesAsync();

            return(Mapper.Map <ProductModel>(product));
        }
예제 #27
0
        public ActionResult Add(ProductAddModel model)
        {
            MyContext context = new MyContext();

            //ProductModel item = new ProductModel
            //{
            //    Id = products.Count + 1,
            //    Name = model.Name,
            //    Image = model.Image
            //};
            //products.Add(item);
            Category c = new Category();

            c.Name = model.Name;
            context.Categories.Add(c);
            context.SaveChanges();

            return(RedirectToAction("Index"));
        }
예제 #28
0
        public async Task AddProduct(ProductAddModel productModel, Guid categoryID)
        {
            var selectedCategory = _context.Categories.Single(c => c.ID == categoryID);

            var p = new Product
            {
                ID           = Guid.NewGuid(),
                ProductName  = productModel.ProductName,
                URLImg       = productModel.URLImg,
                Description  = productModel.Description,
                StockBalance = productModel.StockBalance,
                Price        = productModel.Price,
                Discount     = productModel.Discount,
                Date         = DateTime.Now,
                Sales        = 0,
                Category     = selectedCategory
            };

            _context.Products.Add(p);
            selectedCategory.Products.Add(p);
            await _context.SaveChangesAsync(new CancellationToken());
        }
        public ActionResult Edit(int id, string message)
        {
            var product         = _productservice.GetProductByProductId(id);
            var category1       = _categoryService.GetCategoryByCategoryId(product.CategoryId);
            var productAddModel = new ProductAddModel();
            var categories      = _categoryService.GetAllCategory().Where(x => x.CategoryType == (byte)CategoryType.Category);

            if (!string.IsNullOrEmpty(message))
            {
                productAddModel.ProductAddedCheck = true;
            }
            foreach (var item in categories)
            {
                if (item.ID == category1.ID)
                {
                    productAddModel.Categories.Add(new SelectListItem {
                        Text = item.CategoryName, Value = item.ID.ToString(), Selected = true
                    });
                }
                else
                {
                    productAddModel.Categories.Add(new SelectListItem {
                        Text = item.CategoryName, Value = item.ID.ToString()
                    });
                }
            }
            productAddModel.ProductId          = id;
            productAddModel.BrandName          = product.BrandName;
            productAddModel.Cost               = product.ProductCost;
            productAddModel.ModelName          = product.ModelName;
            productAddModel.Price              = product.ProductPrice;
            productAddModel.ProductName        = product.ProductName;
            productAddModel.ProductNumber      = product.ProductNumber;
            productAddModel.ProductDescription = product.ProductDescription;

            return(View(productAddModel));
        }
        public virtual async Task <JsonResult> Update([FromServices] IWebHostEnvironment env, ProductAddModel model)
        {
            if (!ModelState.IsValid)
            {
                return(Json(new { IsSuccessful = false, Message = ModelState.GetModelError() }));
            }
            model.BaseDomain = _configuration["CustomSettings:BaseUrl"];
            model.Root       = env.WebRootPath;
            var update = await _productSerive.UpdateAsync(model);

            return(Json(new { update.IsSuccessful, update.Message }));
        }