Пример #1
0
        public async Task <IActionResult> AddImgEventAsync(int event_id, IFormFile file)
        {
            string path = "/images/Event/" + file.FileName;

            if (file != null)
            {
                using (var filestream = new FileStream(_appEnvironment.WebRootPath + path, FileMode.Create))
                {
                    await file.CopyToAsync(filestream);
                }
                repository.AddImageForEvent(User.Identity.Name, event_id, new Image {
                    Name = file.FileName, Path = path
                });
            }
            return(RedirectToAction("Settings", "Event", new { id_event = event_id }));
        }