public async Task <IActionResult> Edit(int id, [Bind("StudioId,Name")] Studio studio)
        {
            if (id != studio.StudioId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    await _studioService.UpdateAndSave(studio);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!_studioService.StudioExists(studio.StudioId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(studio));
        }
Esempio n. 2
0
        public async Task UpdateTest()
        {
            var fakeRepository = Mock.Of <IStudioRepository>();
            var studioService  = new StudioService(fakeRepository);

            var studio = new Studio()
            {
                Name = "Test Studio"
            };
            await studioService.UpdateAndSave(studio);
        }