public async Task <IActionResult> Edit(int id, [Bind("Id,Name,LogoPath")] TeamEntity teamEntity)
        {
            if (id != teamEntity.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(teamEntity);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TeamEntityExists(teamEntity.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(teamEntity));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Type,Value,CreatedAt,UpdateAt,CourseId,StudentId,Status")] Mark mark)
        {
            if (HttpContext.Session.GetString("currentLogin") == null)
            {
                return(Redirect("/Authentication/Login"));
            }
            if (id != mark.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(mark);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MarkExists(mark.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CourseId"]  = new SelectList(_context.Course, "Id", "Name", mark.CourseId);
            ViewData["StudentId"] = new SelectList(_context.Student, "Id", "Name", mark.StudentId);
            return(View(mark));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Description,CreatedAt,ExpiredAt,Status")] Course course)
        {
            if (HttpContext.Session.GetString("currentLogin") == null)
            {
                return(Redirect("/Authentication/Login"));
            }
            if (id != course.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(course);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CourseExists(course.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(course));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Email,Password,CreatedAt,UpdatedAt,Status")] Teacher teacher)
        {
            if (id != teacher.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(teacher);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TeacherExists(teacher.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(teacher));
        }
Exemple #5
0
        public Note UpdateNotes(Note Notes, int id)
        {
            var notes = _dbcontext.Notes.Find(id);

            notes.Description = Notes.Description;
            notes.Title       = Notes.Title;
            _dbcontext.Update(notes);

            return(notes);
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Email,Gender,Phone,Address,DoB")] Student student, int[] ClassRoomId)
        {
            if (HttpContext.Session.GetString("currentLogin") == null)
            {
                return(Redirect("/Authentication/Login"));
            }
            if (id != student.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                foreach (var ide in ClassRoomId)
                {
                    var classroom       = _context.ClassRoom.Find(ide);
                    StudentClassRoom sc = new StudentClassRoom
                    {
                        ClassRoom = classroom,
                        Student   = student
                    };
                    _context.Add(sc);
                }
                try
                {
                    _context.Update(student);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!StudentExists(student.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(student));
        }