public async Task <IActionResult> Edit(long id, [Bind("Id,Name")] Specialty specialty)
        {
            if (id != specialty.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    await _specialtyService.EditSpecialty(specialty);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SpecialtyExists(specialty.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(specialty));
        }
Esempio n. 2
0
        public async Task EditSpecialtyTest()
        {
            var fakeRepository   = Mock.Of <ISpecialtyRepository>();
            var specialtyService = new SpecialtyService(fakeRepository);

            var specialty = new Specialty()
            {
                Name = "old name"
            };

            await specialtyService.CreateSpecialty(specialty);

            specialty.Name = "name updated";
            await specialtyService.EditSpecialty(specialty);

            Assert.Equal("name updated", specialty.Name);
        }