コード例 #1
0
        public async Task <ActionResult <int> > Post(Genre genre)
        {
            context.Add(genre);
            await context.SaveChangesAsync();

            return(genre.Id);
        }
コード例 #2
0
        public async Task <ActionResult <int> > Post(Person person)
        {
            if (!string.IsNullOrEmpty(person.Picture))
            {
                var personPicture = Convert.FromBase64String(person.Picture);
                person.Picture = await fileStorageService.SaveFile(personPicture, "jpg", "people");
            }
            context.Add(person);
            await context.SaveChangesAsync();

            return(person.Id);
        }
コード例 #3
0
        public async Task <ActionResult <int> > Post(Movie movie)
        {
            if (!string.IsNullOrEmpty(movie.Poster))
            {
                var moviePoster = Convert.FromBase64String(movie.Poster);
                movie.Poster = await fileStorageService.SaveFile(moviePoster, "jpg", "movies");
            }

            if (movie.MoviesActors != null)
            {
                for (int i = 0; i < movie.MoviesActors.Count; i++)
                {
                    movie.MoviesActors[i].Order = i + 1;
                }
            }
            context.Add(movie);
            await context.SaveChangesAsync();

            return(movie.Id);
        }