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

            if (ModelState.IsValid)
            {
                try
                {
                    await _directorService.UpdateAndSave(director);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!_directorService.DirectorExists(director.DirectorId)) // TODO rework
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(director));
        }
Esempio n. 2
0
        public void DirectorExistsTest()
        {
            int directorId = 1;

            var fakeRepositoryMock = new Mock <IDirectorRepository>();

            fakeRepositoryMock.Setup(x => x.DirectorExists(directorId)).Returns(true);

            var actorService = new DirectorService(fakeRepositoryMock.Object);

            var isExist = actorService.DirectorExists(directorId);

            Assert.True(isExist);
        }