Beispiel #1
0
        public ActionResult AddImageFeatureDetails(ProductModel model)
        {
            using (_dbContext = new karrykartEntities())
            {
                    if (!(String.IsNullOrEmpty(model.Features)))
                    {
                        foreach (var featureText in model.Features.Split(';'))
                        {
                            _dbContext.ProductFeatures.Add(new ProductFeature() { Feature = featureText, ProductID = model.ProductID });
                        }
                    }

                    var lstImages = UploadImage(model);

                    foreach (var image in lstImages)
                    {
                        if (!String.IsNullOrEmpty(image))
                        {
                            _dbContext.ProductImages.Add(new ProductImage() {ImageID=Guid.NewGuid(), ImageLink = image, ProductID = model.ProductID });
                            _dbContext.SaveChanges();
                        }
                    }
                    _logger.WriteLog(CommonHelper.MessageType.Success, "Product imgaes and features added successfully with name=" + model.ProductID, "Create", "ProductController", User.Identity.Name);
                    return RedirectToAction("AddStockPrice", "Product", new { id = model.ProductID });
            }

            return View(model);
        }
Beispiel #2
0
        public ActionResult Create(ProductModel model)
        {
            if (ModelState.IsValid)
            {
                using (_dbContext = new karrykartEntities())
                {
                    var product = new Product()
                    {
                        Active = model.Active,
                        CategoryID = model.CategoryID,
                        CreatedBy = User.Identity.Name,
                        UpdatedBy = User.Identity.Name,
                        Description = model.Description,
                        Name = model.Name,
                        ProductID = Guid.NewGuid(),
                        SubCategoryID = model.SubCategoryID,
                        BrandID = model.BrandID,
                        CreatedOn = DateTime.Now,
                        UpdatedOn = DateTime.Now

                    };
                    _dbContext.Products.Add(product);
                    _dbContext.SaveChanges();
                    _logger.WriteLog(CommonHelper.MessageType.Success, "Product created successfully with name=" + product.ProductID, "Create", "ProductController", User.Identity.Name);
                    return RedirectToAction("AddImageFeatureDetails", "Product", new { id = product.ProductID });
                }

            }
            CreateViewBagForProduct();
            return View();
        }
Beispiel #3
0
        List<string> UploadImage(ProductModel model)
        {
            List<string> lstImageLink = new List<string>();
            if (model.Image1 != null)
                lstImageLink.Add( CommonHelper.UploadFile(model.Image1, _productImages));

            if (model.Image2 != null)
                lstImageLink.Add(CommonHelper.UploadFile(model.Image2, _productImages));

            if (model.Image3 != null)
                lstImageLink.Add(CommonHelper.UploadFile(model.Image3, _productImages));

            return lstImageLink;
        }