Exemple #1
0
        public async Task <IActionResult> DeleteAttributeConfirmed(int ProductId, int FeatureAttributesId, ProductAttribute viewModel)
        {
            if (User.IsInRole(Roles.Client) || !User.Identity.IsAuthenticated)
            {
                return(NotFound());
            }
            await _productAttributeService.Delete(ProductId, FeatureAttributesId);

            return(RedirectToAction(nameof(Index)));
        }
        public async Task <IActionResult> Delete([FromRoute] Int32 id)
        {
            var deleted = await _productAttributeService.Delete(id);

            if (deleted)
            {
                return(Ok(new SuccessResponse
                {
                    message = "Successfully Deleted",
                    status = Ok().StatusCode
                }));
            }
            return(NotFound(new ErrorResponse
            {
                message = "Not Found",
                status = NotFound().StatusCode
            }));
        }
Exemple #3
0
        public async Task <IResult> Delete(int Id)
        {
            var attr = await _productAttributeService.Delete(Id);

            return(attr);
        }
        public ActionResult Edit(Product products, string ProductGalleriesName, string tags)
        {
            if (ModelState.IsValid)
            {
                //------------Create Gallery Product --------------
                List <ProductGallery> productGalleries = new List <ProductGallery>();
                var Gallery = ProductGalleriesName.Split(',');
                for (int i = 0; i < Gallery.Length - 1; i++)
                {
                    productGalleries.Add(new ProductGallery
                    {
                        ProductId = products.ProductId,
                        ImageName = Gallery[i],
                    });
                }
                _productService.AddGalleries(productGalleries);

                //-------------------Tags---------------------
                _productService.DeleteTagsByProduct(products.ProductId);

                if (!string.IsNullOrEmpty(tags))
                {
                    List <ProductTag> productTags = new List <ProductTag>();

                    foreach (string t in tags.Split('-'))
                    {
                        productTags.Add(new ProductTag
                        {
                            ProductId = products.ProductId,
                            TagTitle  = t.ToLowerInvariant().Trim()
                        });
                    }
                    _productService.AddTags(productTags);
                }

                //-----------------Attribute----------------------
                List <Product_Attribut> productAttribut = new List <Product_Attribut>();

                foreach (var atrgrp in _attributeGrpService.GetAttrGrpProductBase(products.ProductGroupId))
                {
                    {
                        //finding product attribute if that is inserted before or not
                        var find = _productAttributeService.GetProductAttribute(products.ProductId, atrgrp.AttributGrpId);

                        if (find != null)
                        {
                            if (Request.Form["Grp_" + atrgrp.AttributGrpId.ToString()] == "none")
                            {
                                _productAttributeService.Delete(find);
                            }
                            //if user clicked one of attribute of this grp
                            else if (Request.Form["Grp_" + atrgrp.AttributGrpId.ToString()] != null)
                            {
                                find.AttributItemId = Convert.ToInt32(Request.Form["Grp_" + atrgrp.AttributGrpId.ToString()]);
                                _productAttributeService.Edit(find);
                            }
                        }
                        else
                        {
                            if (Request.Form["Grp_" + atrgrp.AttributGrpId.ToString()] != null && Request.Form["Grp_" + atrgrp.AttributGrpId.ToString()] != "none")
                            {
                                productAttribut.Add(new Product_Attribut()
                                {
                                    AttributItemId = Convert.ToInt32(Request.Form["Grp_" + atrgrp.AttributGrpId.ToString()]),
                                    ProductId      = products.ProductId,
                                });
                            }
                        }
                    }
                }
                if (productAttribut != null)
                {
                    _productAttributeService.Add(productAttribut);
                }

                //-----------------Details----------------------
                List <ProductDetail> productDetail = new List <ProductDetail>();

                foreach (var detItm in _detailItemService.GetDetItemByProduct(products))
                {
                    var find = _productDetailService.GetProductDetail(products.ProductId, detItm.DetailItemId);
                    if (find != null)
                    {
                        find.Value = Request.Form["detItem_" + detItm.DetailItemId.ToString()];
                        _productDetailService.Edit(find);
                    }
                    else
                    {
                        productDetail.Add(new ProductDetail
                        {
                            DetailItemId = detItm.DetailItemId,
                            ProductId    = products.ProductId,
                            Value        = Request.Form["detItem_" + detItm.DetailItemId.ToString()]
                        });
                    }
                }
                if (productDetail != null)
                {
                    _productDetailService.Add(productDetail);
                }

                _productService.Edit(products);
                ViewBag.tag = tags;
                return(RedirectToAction("/edit/" + products.ProductId));
            }
            ViewBag.ProductGroupId = new SelectList(_productGroupService.ProductGroups(), "ProductGroupId", "GroupTitle", products.ProductGroupId);
            return(View(products));
        }
Exemple #5
0
 public IHttpActionResult Delete(Guid key)
 {
     _productAttributeService.Delete(key);
     _unitOfWorkAsync.Commit();
     return(StatusCode(HttpStatusCode.OK));
 }