Exemplo n.º 1
0
        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" }));
            }
        }
Exemplo n.º 2
0
        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());
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Delete(int id)
        {
            var operationResult = await songService.Delete(id);

            if (!operationResult.IsSuccess)
            {
                return(NotFound(operationResult.Message));
            }
            return(NoContent());
        }
Exemplo n.º 4
0
        public override void Delete(long id)
        {
            IList <Song> songs = songService.FindByAlbumId(id);

            foreach (var song in songs)
            {
                songService.Delete(song.Id);
            }
            base.Delete(id);
        }
Exemplo n.º 5
0
        /// <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);
            }
        }
Exemplo n.º 6
0
        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());
        }
Exemplo n.º 7
0
        public async Task <IActionResult> DeleteSong(int id)
        {
            await _songService.Delete(id);

            return(Ok());
        }
Exemplo n.º 8
0
 public void Delete(long id)
 {
     songService.Delete(id);
 }
Exemplo n.º 9
0
 public void DeleteSong(long id)
 {
     this.WrapInUnitOfWork <Object>(() => { songService.Delete(id); return(null); });
 }
Exemplo n.º 10
0
 public long DeleteById(ObjectId id)
 {
     return(_songService.Delete(id));
 }
Exemplo n.º 11
0
 public void Delete([FromUri] string id)
 {
     _songService.Delete(id);
 }
 public bool Delete(int id)
 {
     return(_songService.Delete(id));
 }