Exemplo n.º 1
0
        public SongModel CreateSong(SongModel newSong)
        {
            var songEntity    = mapper.Map <SongEntity>(newSong);
            var newSongEntity = repository.CreateSong(songEntity);

            return(mapper.Map <SongModel>(newSongEntity));
        }
Exemplo n.º 2
0
        public ActionResult Add(FormCollection formValues, Song model)
        {
            if ((formValues != null) && (formValues["Save"] != null) && (ModelState.IsValid))
            {
                _songRepository.CreateSong(Config.MainAdminId, model);
                return(RedirectToRoute("AdminSongIndex"));
            }

            return(View());
        }
Exemplo n.º 3
0
        public async Task <int> CreateSong(Song song)
        {
            var songInDb = await _songRepository.GetSongByFullName(song.Band, song.Name);

            if (songInDb != null)
            {
                throw new TypedException(ExceptionType.BadRequest, "Current song is already exists");
            }

            return(await _songRepository.CreateSong(song));
        }
Exemplo n.º 4
0
        public async Task <bool> CreateSong(SongCreateDTO dto)
        {
            var rao    = _mapper.Map <SongCreateRAO>(dto);
            var engine = new SaveFileEngine();
            var uri    = engine.Upload(dto.UploadedFile);

            rao.UploadedLink = uri;

            if (await _repository.CreateSong(rao))
            {
                return(true);
            }

            throw new NotImplementedException();
        }
Exemplo n.º 5
0
        public IHttpActionResult CreateSong([FromBody] Song song)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }
            Song newSong;

            try
            {
                newSong = _songRepository.CreateSong(song);
            }
            catch (Exception e)
            {
                return(InternalServerError(e));
            }

            return(Created(new Uri(Request.RequestUri + "/" + song.SongID), newSong));
        }