Ejemplo n.º 1
0
        public async Task <ActionResult <string> > AddShow(AddShowModel show)
        {
            var requestHasAdminUserClaim = User.Claims.Where(claim => claim.Type == "user" && claim.Value == "1").ToList().Count > 0;

            if (!requestHasAdminUserClaim)
            {
                return(BadRequest($"You do not have permissions add shows."));
            }

            var showAdded = await _repository.AddShow(show).ConfigureAwait(false);

            if (!showAdded)
            {
                return(StatusCode(500, "Failed to add show."));
            }

            return(Ok("Show successfully added."));
        }
Ejemplo n.º 2
0
        public async Task <bool> AddShow(AddShowModel show)
        {
            if (show == null || show.ShowName == null)
            {
                throw new ArgumentNullException(nameof(show));
            }

            var showToAdd = new EntityFrameworkEntities.Show
            {
                Name = show.ShowName
            };

            await _context.Show.AddAsync(showToAdd).ConfigureAwait(false);

            await _context.SaveChangesAsync().ConfigureAwait(false);

            return(true);
        }