public IActionResult Delete(int id)
        {
            if (!ModelState.IsValid)
            {
                return(new BadRequestObjectResult(ModelState));
            }

            _advertisementService.Delete(id);
            _advertisementService.Save();

            return(new OkObjectResult(id));
        }
        public async Task <ActionResult> Delete(int id)
        {
            var userId = User.GetId();

            var isDeleted = await _advertisementService.Delete(id, userId);

            if (!isDeleted)
            {
                return(BadRequest());
            }

            return(Ok());
        }
        public HttpResponseMessage Delete(int id)
        {
            var advertisement = _advertisementService.GetAdvertisementById(id);

            if (_advertisementService.Delete(advertisement))
            {
                return(PageHelper.toJson(PageHelper.ReturnValue(true, "数据删除成功")));
            }
            else
            {
                return(PageHelper.toJson(PageHelper.ReturnValue(false, "数据删除失败")));
            }
        }
        public async Task <ActionResult <bool> > Delete(Guid id)
        {
            try
            {
                var res = await _advService.Delete(id);

                return(new OkObjectResult(res));
            }
            catch (Exception exception)
            {
                _logger.LogError(exception.Message);
                throw exception;
            }
        }
Example #5
0
 public async Task <IActionResult> Delete(int Id)
 {
     try
     {
         var advertisement = _advertisementService.Select().Result?.Where(src => src.Id == Id).FirstOrDefault();
         if (advertisement == null)
         {
             return(NotFound());
         }
         await _advertisementService.Delete(advertisement);
     }
     catch (Exception ex)
     {
         NotifyError(ex.Message);
     }
     return(CustomResponse(Id));
 }
Example #6
0
        public JsonResult Delete(int id = 0)
        {
            try
            {
                var entity = _AdvertisementService.GetById(id);

                if (entity == null)
                {
                    return(Json(new { Status = Successed.Empty }, JsonRequestBehavior.AllowGet));
                }

                _AdvertisementService.Delete(entity);

                return(Json(new { Status = Successed.Ok }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                return(Json(new { Status = Successed.Error }, JsonRequestBehavior.AllowGet));
            }
        }
Example #7
0
        public ActionResult Delete(int id)
        {
            try
            {
                var advertisement = _advertisementService.GetByID(id);
                _advertisementService.Delete(id);

                var advertisements = _advertisementService.GetAll().Where(ad => ad.DisplayOrder > advertisement.DisplayOrder).ToList();

                advertisements.ForEach(ad => ad.DisplayOrder--);

                _advertisementService.SaveChanges();

                return(RedirectToAction("Index", "Advertisement"));
            }
            catch (Exception)
            {
                return(RedirectToAction("Index", "Advertisement"));
            }
        }
Example #8
0
        public async Task <CustomApiResponse> Delete(string id)
        {
            var result = await _advertisementService.Delete(id);

            return(new CustomApiResponse(id, result ? "Succeeded" : "Failed", !result));
        }
Example #9
0
 public bool Delete(AdvertisementModel model)
 {
     return(service.Delete(model).Result > 0);
 }