Пример #1
0
        public ActionResult DeleteImage(int?idHinhAnh, int?idSanPham)
        {
            var result = new ReponseMessage();

            try
            {
                // TODO: Add delete logic here
                bool kq = false;
                if (idSanPham.HasValue && idSanPham.Value > 0)
                {
                    kq = sanPhamService.DeletePrimaryImage(idSanPham);
                }
                else if (idHinhAnh.HasValue && idHinhAnh.Value > 0)
                {
                    kq = sanPhamService.DeleteImage(idHinhAnh.Value);
                }
                if (kq == false)
                {
                    result.Message    = "Không tìm thấy hình ảnh";
                    result.StatusCode = HttpStatusCode.NotFound;
                    return(Json(result));
                }
                result.StatusCode = HttpStatusCode.OK;
                return(Json(result));
            }
            catch (Exception ex)
            {
                result.Message    = "Có lỗi trong quá trình xử lý";
                result.StatusCode = HttpStatusCode.ExpectationFailed;
                return(Json(result));
            }
        }