Exemplo n.º 1
0
        //Product Functions

        public int AddProduct(ProductDTO obj)
        {
            ProductProvider provider = new ProductProvider();

            if (provider.GetProductById(obj.ProductId) == null)
            {
                provider.AddProduct(obj);
                return(1);
            }
            return(-1);
        }
Exemplo n.º 2
0
        public Guid AddProductToStore(ProductInput input)
        {
            var     slug     = input.ProductName.CreateSlug();
            var     tenantId = AbpSession.TenantId ?? 1;
            Product instance;

            if (input.Id.HasValue)
            {
                instance = _productManager.GetProduct(input.Id.Value);
                instance.SetSlug(instance.ProductName.CreateSlug());
                instance = input.MapTo(instance);
            }
            else
            {
                instance = Product.CreateProduct(input.ProductName,
                                                 input.AvailableStock,
                                                 input.TrackStock,
                                                 input.ProductPrice,
                                                 input.ProductDescription,
                                                 input.Sku,
                                                 input.IsFeatured,
                                                 input.ProductName.CreateSlug());
                if (input.Active)
                {
                    instance.Active = input.Active;
                }
            }

            if (input.Imagen.ContentLength > 0)
            {
                //Small image
                var formatedFolderSmall = string.Format(ImageFolder, tenantId, slug, FolderSizeSmall);
                var smallImage          = _imageManager.SaveImage(250, 250, input.Imagen, formatedFolderSmall);
                //Medium Image
                var formatedFolderMed = string.Format(ImageFolder, tenantId, slug, FolderSizeMedium);
                var medImage          = _imageManager.SaveImage(650, 350, input.Imagen, formatedFolderMed);

                //Default Image
                var formatedFolderDef = string.Format(ImageFolder, tenantId, slug, FolderSizeDefault);
                var defImage          = _imageManager.SaveImage(null, null, input.Imagen, formatedFolderDef);


                instance.SetMainImage(defImage);
                instance.SetMedImage(medImage);
                instance.SetSmallImage(smallImage);
                instance.SetDataImage(input.DataImage);
            }


            var id = _productManager.AddProduct(instance);

            return(id);
        }
Exemplo n.º 3
0
        public ActionResult Create(CreateEditViewModel model)
        {
            var product = new Product();

            mapper.Map(model, product);

            try
            {
                productProvider.AddProduct(product);
            }
            catch (Exception ex)
            {
                return(HandleException(ex));
            }
            var jsonViewModel = new AjaxViewModel(true, model, null);

            return(Json(jsonViewModel));
        }
Exemplo n.º 4
0
        public ActionResult AddProduct(ProductModel model)
        {
            DATA.Domains.Product product = new DATA.Domains.Product
            {
                CreatedOn     = DateTime.Now,
                Name          = model.Name,
                ProductTypyId = model.ProductTypeId,
                Size          = model.Size,
                IsActive      = true,
                IsDeleted     = false
            };
            productProvider.AddProduct(product);

            TempData["alert"] = GetAlert("Product added successfully", "success");

            var productType = productProvider.GetProductType();

            TempData["ProductType"] = productType;

            return(RedirectToAction("Product"));
        }