Ejemplo n.º 1
0
        public IActionResult Delete([FromForm] CarImage entity)
        {
            var result = _carImageManager.Delete(entity);

            if (result.Success)
            {
                return(Ok(result.Message));
            }
            return(BadRequest(result.Message));
        }
Ejemplo n.º 2
0
        public IActionResult Delete([FromForm(Name = ("Id"))] int Id)
        {
            var carImage = _carImageManager.Get(Id).Data;
            var result   = _carImageManager.Delete(carImage);

            if (result.Success)
            {
                return(Ok(result));
            }
            return(BadRequest(result));
        }
Ejemplo n.º 3
0
        public IActionResult Delete(CarImage carImage)
        {
            var result = _carImageManager.Delete(carImage);

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

            return(BadRequest(result));
        }
Ejemplo n.º 4
0
        public IActionResult Delete([FromForm] CarImage entity)
        {
            var result = _carImageManager.Delete(entity);

            if (result.Success)
            {
                System.IO.File.SetAttributes(_environment.WebRootPath + entity.ImagePath, FileAttributes.Normal);
                System.IO.File.Delete(_environment.WebRootPath + entity.ImagePath);
                return(Ok(result.Message));
            }
            return(BadRequest(result.Message));
        }
Ejemplo n.º 5
0
        private void DeleteImages(CarItem dbItem, IEnumerable <int> ids)
        {
            var dbImagesArrayForDelete = dbItem.CarImages.Where(x => ids.Contains(x.Id)).ToList();

            foreach (var item in dbImagesArrayForDelete)
            {
                //remove from dbitem
                dbItem.CarImages.Remove(item);
                //remove from database
                _carImageManager.Delete(item);
            }
        }