Esempio n. 1
0
        public string Create(ArtistServiceModel artistService)
        {
            var artist = new Artist()
            {
                Name        = artistService.Name,
                Image       = artistService.Image,
                Description = artistService.Description
            };

            context.Artists.Add(artist);
            context.SaveChanges();

            return(artist.Id);
        }
Esempio n. 2
0
        public IActionResult SaveSong(string songId)
        {
            if (ModelState.IsValid)
            {
                var s = _context.Songs.FirstOrDefault(x => x.Id == songId);

                var usr = _context.Catalogs.FirstOrDefault(x => x.UserId == AccountService.UsrId);

                if (usr != null && s != null)
                {
                    var u = usr.Songs.FirstOrDefault(x => x.Name == s.Name);
                    if (u == null)
                    {
                        return(Json(new { status = "error", message = "This song is already added in playlist" }));
                    }
                    else
                    {
                        usr.Songs.Add(s);
                        _context.SaveChanges();
                        return(this.View());
                    }
                }
                else
                {
                    return(NotFound());
                }
            }
            return(NotFound());
        }
Esempio n. 3
0
        public string Update(CreateUserViewModel userService, string id)
        {
            var user = context.Users.FirstOrDefault(x => x.Id == id);

            if (user == null)
            {
                return("not found");
            }
            else
            {
                user.Username  = userService.Username;
                user.FirstName = userService.FirstName;
                user.LastName  = userService.LastName;
                user.Password  = userService.Password;

                context.Users.Update(user);
                context.SaveChanges();

                return(user.Id);
            }
        }
Esempio n. 4
0
        public string Create(string name, string artistId, DateTime releaseDate)
        {
            var artis = context.Artists.FirstOrDefault(x => x.Name == artistId);

            if (artis == null)
            {
                return("not found");
            }
            Album album = new Album()
            {
                Name        = name,
                ArtistId    = artistId,
                Artist      = artis,
                ReleaseDate = releaseDate
            };

            artis.Albums.Add(album);
            context.Albums.Add(album);
            context.SaveChanges();

            return(album.Id);
        }