Пример #1
0
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            bool Result = _noticeBoardManager.DeleteNotice(id.Value);

            if (Result)
            {
                var image = _data.SiteImages.FirstOrDefault(x => x.TypeId == id && x.Type == "Notice");

                if (image != null && !image.ImagePath.Contains("defaultNotice"))
                {
                    var path = Path.Combine(Server.MapPath(image.ImagePath));

                    System.IO.File.Delete(path);

                    _data.SiteImages.Remove(image);
                    _data.SaveChanges();
                }
            }

            return(Content(Result.ToString()));
        }