public Genre Insert(Genre genre)
        {
            _context.Genre.Add(genre);
            _context.SaveChanges();

            return(_context.Genre.Last());
        }
        public SongGetRequest Insert(SongInsertRequest song)
        {
            var entity = _mapper.Map <Song>(song);

            _context.Song.Add(entity);
            _context.SaveChanges();

            return(_mapper.Map <SongGetRequest>(_context.Song.Last()));
        }
Exemple #3
0
        public Performer Insert(PerformerInsertRequest obj)
        {
            var entity = _mapper.Map <Performer>(obj);

            _context.Performer.Add(entity);
            _context.SaveChanges();

            return(_context.Performer.Last());
        }
        public Album Insert(AlbumInsertRequest album)
        {
            var entity = _mapper.Map <Album>(album);

            _context.Album.Add(entity);
            _context.SaveChanges();

            return(_context.Album.Last());;
        }
Exemple #5
0
        public bool RateAlbum(UsersAlbumRate obj)
        {
            var entity = _context.UsersAlbumRates.Find(obj.AlbumId, obj.UserId);

            if (entity != null)
            {
                if (entity.AlbumId.Equals(obj.AlbumId) && entity.UserId.Equals(obj.UserId))
                {
                    return(false);
                }
            }
            _context.UsersAlbumRates.Add(obj);
            _context.SaveChanges();
            return(true);
        }
        public UserGetRequest Insert(UserInsertRequest obj)
        {
            if (!obj.Password.Equals(obj.PasswordConfirmation))
            {
                //todo
                //vjv custom exceptione ce trebat napravit
            }

            var entity = _mapper.Map <User>(obj);

            entity.Salt = GenerateSalt();
            entity.Hash = GenerateHash(entity.Salt, obj.Password);

            _context.User.Add(entity);
            _context.SaveChanges();

            return(_mapper.Map <UserGetRequest>(_context.User.Last()));
        }