public ActionResult DeleteSong(int SongId) { var song = _songService.GetById(SongId); if (CanDelete(song)) { //the logged in user can delete the page. lets delete the associated things now while (song.Pictures.Count() != 0) { foreach (var songpicture in song.Pictures) { var picture = _pictureService.GetPictureById(songpicture.PictureId); _songService.DeletePicture(songpicture); _pictureService.DeletePicture(picture); //collection modified. so better break the loop and let it run agian. break; } } _songService.Delete(song); return(Json(new { Success = true })); } else { return(Json(new { Success = false, Message = "Unauthorized" })); } }
public IActionResult Delete(int id) { if (!UserIsInRole(UserTypeEnum.Admin)) { return(Unauthorized("You are not in role to permit this action")); } _service.Delete(id); return(Ok()); }
public async Task <IActionResult> Delete(int id) { var operationResult = await songService.Delete(id); if (!operationResult.IsSuccess) { return(NotFound(operationResult.Message)); } return(NoContent()); }
public override void Delete(long id) { IList <Song> songs = songService.FindByAlbumId(id); foreach (var song in songs) { songService.Delete(song.Id); } base.Delete(id); }
/// <summary> /// Deletes song with given Id /// </summary> /// <param name="id">Id of the song to delete</param> public async Task <bool> DeleteSongAsync(Guid id) { using (var uow = UnitOfWorkProvider.Create()) { if ((await songService.GetAsync(id, false)) == null) { return(false); } songService.Delete(id); await uow.Commit(); return(true); } }
public IActionResult DeleteSong(long id) { var result = _songService.Delete(id); if (!result.Success) { if (result.Exception is ArgumentOutOfRangeException) { return(NotFound()); } else { return(BadRequest(result)); } } return(NoContent()); }
public async Task <IActionResult> DeleteSong(int id) { await _songService.Delete(id); return(Ok()); }
public void Delete(long id) { songService.Delete(id); }
public void DeleteSong(long id) { this.WrapInUnitOfWork <Object>(() => { songService.Delete(id); return(null); }); }
public long DeleteById(ObjectId id) { return(_songService.Delete(id)); }
public void Delete([FromUri] string id) { _songService.Delete(id); }
public bool Delete(int id) { return(_songService.Delete(id)); }