示例#1
0
 public RedirectToActionResult AddShow(Show show)
 {
     if (ModelState.IsValid)
     {
         repo.AddShow(show);
         return(RedirectToAction("AddVenue"));
     }
     return(RedirectToAction());
 }
        public async Task <IActionResult> Add(Show entity, IFormFile file)
        {
            var path = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "img", "shows", file.FileName);

            using (var stream = new FileStream(path, FileMode.Create))
            {
                await file.CopyToAsync(stream);
            }
            entity.Image = file.FileName;
            ShowRepository.AddShow(entity);
            return(RedirectToAction("List"));
        }
示例#3
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."));
        }
示例#4
0
 public void AddShow(Show show)
 {
     repository.AddShow(show);
 }