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()); }
/// <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)); } }
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")); }
public void Delete(int id) { _albumManager.Delete(id); }