コード例 #1
0
        public IHttpActionResult Delete(int id)
        {
            var userId = Request.GetUserId();

            if (userId < 0)
            {
                return(Unauthorized());
            }

            var album = _albumManager.GetById(id);

            if (album == null)
            {
                return(NotFound());
            }

            if (!_authManager.HasAccess(userId, album, Operation.Delete))
            {
                return(Unauthorized());
            }

            _albumManager.Delete(album.Id);

            return(Ok());
        }
コード例 #2
0
        /// <summary>
        /// Method to delete an <see cref="AlbumEntity"/>.
        /// </summary>
        /// <param name="entity">The <see cref="AlbumEntity"/> to delete.</param>
        /// <param name="save">Save changes ?</param>
        /// <returns>The deleted <see cref="AlbumEntity"/>.</returns>
        public AlbumEntity Delete(AlbumEntity entity)
        {
            if (entity == null)
            {
                return(null);
            }

            using (Db.Context)
            {
                Db.Context.Albums.Attach(entity);
                return(AlbumManager.Delete(entity));
            }
        }
コード例 #3
0
        public ActionResult DeleteConfirm(string id)
        {
            if (!AlbumManager.Exist(id))
            {
                return(RedirectToAction("NotFound", "Error"));
            }

            string oldCover = _db.tbl_Album.SingleOrDefault(a => a.album_Id == id).album_Cover;

            if (oldCover != "Album_1.jpg")
            {
                ImageManager.Delete(Server.MapPath("~/Content/Album/" + oldCover));
            }
            AlbumManager.Delete(id);
            return(RedirectToAction("Index"));
        }
コード例 #4
0
 public void Delete(int id)
 {
     _albumManager.Delete(id);
 }