/// <summary>
        ///     删除产品图
        /// </summary>
        /// <param name="ParamenterID">产品图Id</param>
        /// <returns></returns>
        /// <remarks>added by jimmy,2015-7-3</remarks>
        public JsonResult Delete(long?productImageId)
        {
            var resultModel = new ResultModel();

            if (productImageId.HasValue)
            {
                var result = _productImageService.Delete(productImageId.Value).Data;
                if (result > 0)
                {
                    resultModel.IsValid  = true;
                    resultModel.Messages = new List <string> {
                        "Delete product picture success"
                    };
                }
                else
                {
                    resultModel.IsValid  = false;
                    resultModel.Messages = new List <string> {
                        "Delete product picture failed"
                    };
                }
            }
            else
            {
                resultModel.IsValid  = false;
                resultModel.Messages = new List <string> {
                    "Key ID error"
                };
            }
            var opera = string.Format("删除产品图 productImageId:{0},操作结果:{1}", productImageId, resultModel.IsValid ? "成功" : "失败");

            LogPackage.InserAC_OperateLog(opera, "企业信息--产品图");
            return(Json(resultModel, JsonRequestBehavior.AllowGet));
        }
        public HttpResponseMessage Delete(HttpRequestMessage request, int id)
        {
            _productImageService.Delete(id);
            _productImageService.Save();

            return(request.CreateResponse(HttpStatusCode.OK, id));
        }
Example #3
0
        public IActionResult DeleteImageConfirmed(int id)
        {
            var image = productImageService.GetById(id);

            productImageService.Delete(image);
            return(RedirectToAction(nameof(Index)));
        }
Example #4
0
        public void DeleteListImageOnProductImageTable(IEnumerable <HttpPostedFileBase> httpPostedFileBases, Guid ProVaId)
        {
            string local = Server.MapPath("~/Content/img/product-men");

            foreach (var proImage in _productImageService.GetProductImageList(ProVaId))
            {
                _productImageService.Delete(proImage);
            }
        }
        //        [Permission(Action = ActionName.CanDelete)]
        public IHttpActionResult DeleteProductImage(int id)
        {
            return(CreateResponse(() =>
            {
                _productImageService.Delete(id);
                UnitOfWork.Commit();

                return StatusCode(HttpStatusCode.NoContent);
            }));
        }
Example #6
0
        public IActionResult Delete([FromForm(Name = ("Id"))] int id)
        {
            var productImage = _productImageService.GetById(id).Data;
            var result       = _productImageService.Delete(productImage);

            if (result.Success)
            {
                return(Ok(result));
            }
            return(BadRequest(result));
        }
 public HttpResponseMessage Delete(HttpRequestMessage request, int id)
 {
     return(CreateHttpResponse(request, () =>
     {
         HttpResponseMessage response = null;
         _productImageService.Delete(id);
         _productImageService.Save();
         response = request.CreateResponse(HttpStatusCode.OK, "Xóa thành công");
         return response;
     }));
 }
Example #8
0
        public IActionResult Delete(ProductImage productImage)
        {
            var result = _productImageService.Delete(productImage);

            if (result.Success)
            {
                return(Ok(result));
            }

            return(BadRequest(result));
        }
Example #9
0
        public ActionResult <ProductImage> DeleteProductImage(int id)
        {
            var productImage = productImageService.GetProductImageById(id);

            if (productImage == null)
            {
                return(NotFound());
            }

            productImageService.Delete(productImage);
            return(productImage);
        }
Example #10
0
        [HttpPost("update")]//++++
        public async Task <IActionResult> Update([FromForm] ProductUpdateDto product)
        {
            var update = await _productService.Update(product);

            if (update.Success)
            {
                var imageList = await _productImageService.GetByImageId(product.Id);  //ürüne ait resimleri alır.

                var deletingImage = imageList.Data.Where(w => !product.oldImageName.Contains(w.ImageName)).ToList();
                if (deletingImage.Count != 0)
                {
                    List <string> images = new List <string>();
                    foreach (var item in deletingImage)
                    {
                        images.Add(item.ImageName);
                    }
                    var deleteEntity = await _productImageService.Delete(images);

                    if (images != null)
                    {
                        var resimler = Path.Combine(_environment.WebRootPath, "productImage");//dizin bilgisi
                        foreach (var item in images)
                        {
                            System.IO.File.Delete(resimler + "\\" + item);
                        }
                    }
                }

                if (product.NewImages != null)
                {
                    var           resimler  = Path.Combine(_environment.WebRootPath, "productImage");//dizin bilgisi
                    List <string> newImages = new List <string>();
                    foreach (var item in product.NewImages)
                    {
                        string imageName = $"{Guid.NewGuid().ToString()}.jpg";//Db ye kaydedilecek olan resimlerin ismi
                        using (var fileStream = new FileStream(Path.Combine(resimler, imageName), FileMode.Create))
                        {
                            newImages.Add(imageName);
                            await item.CopyToAsync(fileStream);
                        }
                    }
                    var saveImage = await _productImageService.Add(newImages, product.Id);

                    if (saveImage.Success)
                    {
                        return(Ok(update.Message));
                    }
                    return(BadRequest("Resimler yüklenirken hata oluştu"));
                }
                return(Ok(update.Message));
            }
            return(BadRequest(update.Message));
        }
 public HttpResponseMessage Delete(HttpRequestMessage request, int id)
 {
     return(CreateHttpResponse(request, () =>
     {
         ProductImage produtImage = _productImageService.GetByID(id);
         string pathImage = produtImage.Path;
         _productImageService.Delete(id);
         _productImageService.Save();
         DeleteElementImage(pathImage);
         return request.CreateResponse(HttpStatusCode.OK, id);
     }));
 }
Example #12
0
 public ActionResult <ProductImage> Delete(int id)
 {
     if (null == _ProductImageService.FindProductImageWithID(id))
     {
         return(BadRequest("There is no ProductImage with this ID."));
     }
     else
     {
         _ProductImageService.Delete(id);
         return(Ok("ProductImage deleted."));
     }
 }
Example #13
0
        public async Task <IActionResult> DeleteProductImage(int productImageId)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var result = await _productImageService.Delete(productImageId);

            if (!result.IsSuccessed)
            {
                return(BadRequest(result.Message));
            }
            return(Ok());
        }
Example #14
0
        public async Task <IActionResult> Delete(int id)
        {
            var hasPermission = await _authorizationService.AuthorizeAsync(User, "PRODUCT", Operations.Delete);

            if (hasPermission.Succeeded == false)
            {
                return(new BadRequestObjectResult(CommonConstants.Forbidden));
            }
            ProductImageViewModel productImageVm = _productImageService.GetById(id);

            _productImageService.Delete(id);
            _productImageService.SaveChanges();
            productImageVm.Path.DeletementByString(_env);
            return(new OkObjectResult(id));
        }
        public HttpResponseMessage Delete(HttpRequestMessage request, int id)
        {
            var identity = (ClaimsIdentity)User.Identity;
            IEnumerable <Claim> claims = identity.Claims;

            _productImageService.Delete(id);
            _productImageService.Save();
            Log log = new Log()
            {
                AppUserId = claims.FirstOrDefault().Value,
                Content   = Notification.DELETE_PRODUCTIMG,
                Created   = DateTime.Now
            };

            _logService.Create(log);
            _logService.Save();
            return(request.CreateResponse(HttpStatusCode.OK, id));
        }
Example #16
0
        public async Task <IActionResult> Delete(int id)
        {
            var result = await _ProductImageService.Delete(id);

            return(Ok(result));
        }