Esempio n. 1
0
        public async Task <IActionResult> Create(Banner viewModel, IFormFile file)
        {
            if (User.IsInRole(Roles.Client) || !User.Identity.IsAuthenticated)
            {
                return(NotFound());
            }
            if (ModelState.IsValid)
            {
                await _bannerService.AddFile(viewModel, file);

                var Id = await _bannerService.Add(viewModel);

                if (!String.IsNullOrEmpty(Request.Form["continue"]))
                {
                    return(RedirectToAction("Edit", new { Id = Id }));
                }
                if (!String.IsNullOrEmpty(Request.Form["new"]))
                {
                    return(RedirectToAction(nameof(Create)));
                }
                return(RedirectToAction(nameof(Index)));
            }

            return(View(viewModel));
        }