public async Task <IActionResult> Edit(int id, [Bind("CourseRegId,StudentId,CourseId")] StudentCourse studentCourse)
        {
            if (id != studentCourse.CourseRegId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(studentCourse);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!StudentCourseExists(studentCourse.CourseRegId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(studentCourse));
        }
示例#2
0
        public async Task <IActionResult> Edit(int id, [Bind("InstructorId,FirstName,LastName,EmailAddress,Course")] Instructor instructor)
        {
            if (id != instructor.InstructorId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(instructor);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!InstructorExists(instructor.InstructorId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(instructor));
        }
        public async Task <IActionResult> Edit(int id, [Bind("StudentId,FirstName,LastName,EmailAddress,PhoneNumber,Course")] Student student)
        {
            if (id != student.StudentId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(student);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!StudentExists(student.StudentId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(student));
        }
        public async Task <IActionResult> Edit(int id, [Bind("PhraseId,src,dst")] Phrase phrase)
        {
            if (id != phrase.PhraseId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(phrase);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PhraseExists(phrase.PhraseId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(phrase));
        }
        public async Task <IActionResult> Edit(int id, [Bind("CourseId,CourseNumber,CourseName,Description")] Course course)
        {
            if (id != course.CourseId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(course);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CourseExists(course.CourseId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(course));
        }
        public void Update_OnEmptyDb_ReturnsFalse()
        {
            var mock = GetMockDependency <Product>();
            var obj  = new LocalDbContext <Product>(mock);

            var actual = obj.Update(new Product {
                Id = 1
            });

            Assert.False(actual);
        }
 public void Update(Phrase phrase)
 {
     context.Update(phrase);
 }