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 void DirectorExistsTest()
        {
            int studioId = 1;

            var fakeRepositoryMock = new Mock <IStudioRepository>();

            fakeRepositoryMock.Setup(x => x.StudioExists(studioId)).Returns(true);

            var studioService = new StudioService(fakeRepositoryMock.Object);

            var isExist = studioService.StudioExists(studioId);

            Assert.True(isExist);
        }