Ejemplo n.º 1
0
        public bool DeleteAdvertise(int ID)
        {
            if (ID <= 0)
            {
                throw new HttpResponseException()
                      {
                          Status = (int)ApiResultModel.CodeEnum.IllegalRequest
                      };
            }

            string physicalPath = $"{_hostingEnvironment.ContentRootPath}{_config.GetValue<string>("ImagesUploadPath")}";

            AdvertiseCondition condition = new AdvertiseCondition();

            condition.ID = ID;

            Advertise advertise = _advertiseService.SearchAdvertises(condition).FirstOrDefault();

            if (advertise == null)
            {
                throw new HttpResponseException()
                      {
                          Status = (int)ApiResultModel.CodeEnum.ObjectNotFound
                      };
            }

            CommonUtilities.DeleteImageFromUrl(advertise.ResourceUrl, physicalPath, _config.GetValue <string>("ImagesUploadPath"));

            return(_advertiseService.DeleteAdvertise(ID));
        }
        public ActionResult DeleteAdvertise(Advertise advertise)
        {
            Log.Debug($"Deleting {advertise.Title}");

            try
            {
                advertiseService.DeleteAdvertise(advertise);
            }
            catch (Exception e)
            {
                Log.Error(e.ToString());
            }

            return(RedirectToAction("Advertises"));
        }
Ejemplo n.º 3
0
 public ActionResult DeleteAdvertise(Advertise advertise)
 {
     advertiseService.DeleteAdvertise(advertise);
     return(RedirectToAction("GetAllAdvertises"));
 }