Пример #1
0
        public async Task <IActionResult> Edit(int id, [Bind("ShowId,ShowName,Country,City,StreetName,HouseNumber,ShowTime,ShowImagePath")] ShowModel showModel)
        {
            if (id != showModel.ShowId)
            {
                return(NotFound());
            }

            ShowModel orig = _context.Shows.AsNoTracking().Where(s => s.ShowId == id).FirstOrDefault();

            showModel.ShowImagePath = orig.ShowImagePath;

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(showModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ShowModelExists(showModel.ShowId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(showModel));
        }
Пример #2
0
        public async Task <IActionResult> Create([Bind("ShowId,ShowName,Country,City,StreetName,HouseNumber,ShowTime")] ShowModel showModel, IFormFile showImagePath)
        {
            showModel.ShowImagePath = FileHelper.SaveFile(showImagePath, "images", showImagePath.FileName);
            if (ModelState.IsValid)
            {
                _context.Add(showModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(showModel));
        }