Ejemplo n.º 1
0
        public async Task <IActionResult> Create([Bind("Id,Name,Status,DateStart,DateEnd")] Term term)
        {
            Staff Staff = await StaffUserAsync();

            term.InstitutionId = Staff.InstitutionId;
            if (ModelState.IsValid)
            {
                if (term.Status)
                {
                    var entries = _context.Term.Where(x => x.Status == true);
                    if (entries != null)
                    {
                        foreach (var entry in entries)
                        {
                            entry.Status = false; _context.Update(entry);
                        }
                    }
                }
                _context.Add(term);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index", "Configurations"));;
            }
            return(View(term));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,FirstName,LastName,OtherNames,ClassId,Guid,Sex,Address,ParentId,Dob,SchoolId,Status,InstitutionId")] Student student)
        {
            if (id != student.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(student);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!StudentExists(student.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ClassId"]       = new SelectList(_context.Class, "Id", "Name", student.ClassId);
            ViewData["InstitutionId"] = new SelectList(_context.Institution, "Id", "Name", student.InstitutionId);
            ViewData["ParentId"]      = new SelectList(_context.Parent, "Id", "Address", student.ParentId);
            ViewData["SchoolId"]      = new SelectList(_context.School, "Id", "Logo", student.SchoolId);
            return(View(student));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,StaffId,SubjectId,ClassId")] StaffSubject staffSubject)
        {
            if (id != staffSubject.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(staffSubject);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!StaffSubjectExists(staffSubject.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index", "Configurations"));
            }
            ViewData["ClassId"]   = new SelectList(_context.Class, "Id", "Name", staffSubject.ClassId);
            ViewData["StaffId"]   = new SelectList(_context.Staff, "Id", "Address", staffSubject.StaffId);
            ViewData["SubjectId"] = new SelectList(_context.Subject, "Id", "Name", staffSubject.SubjectId);
            return(View(staffSubject));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] Subject subject)
        {
            if (id != subject.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(subject);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SubjectExists(subject.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index", "Configurations"));
            }
            return(View(subject));
        }
        public async Task<IActionResult> Edit(int id, [Bind("Id,AssessmentTypeId,SchoolId,MaxScore,NoOfItems")] ResultType resultType)
        {
            if (id != resultType.Id)
            {
                return NotFound();
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(resultType);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ResultTypeExists(resultType.Id))
                    {
                        return NotFound();
                    }
                    else
                    {
                        throw;
                    }
                }
                return RedirectToAction("Index", "Configurations");
            }
            ViewData["AssessmentTypeId"] = new SelectList(_context.AssessmentType, "Id", "Name", resultType.AssessmentTypeId);
            ViewData["SchoolId"] = new SelectList(_context.School, "Id", "Logo", resultType.SchoolId);
            return View(resultType);
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,SchoolId,StaffId")] Class @class)
        {
            if (id != @class.Id)
            {
                return(NotFound());
            }

            Staff Staff = await StaffUserAsync();

            @class.InstitutionId = Staff.InstitutionId;
            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(@class);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ClassExists(@class.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index", "Configurations"));
            }
            ViewData["SchoolId"] = new SelectList(_context.School, "Id", "Logo", @class.SchoolId);
            ViewData["StaffId"]  = new SelectList(_context.Staff, "Id", "Address", @class.StaffId);
            return(View(@class));
        }
Ejemplo n.º 7
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Logo")] School school)
        {
            if (id != school.Id)
            {
                return(NotFound());
            }
            Staff Staff = await StaffUserAsync();

            school.InstitutionId = Staff.InstitutionId;
            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(school);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SchoolExists(school.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index", "Configurations"));
            }
            return(View(school));
        }
        public async Task <IActionResult> Create([Bind("Id,Name,Status")] Session session)
        {
            if (ModelState.IsValid)
            {
                if (session.Status)
                {
                    var entries = _context.Session.Where(x => x.Status == true);
                    if (entries != null)
                    {
                        foreach (var entry in entries)
                        {
                            entry.Status = false; _context.Update(entry);
                        }
                    }
                }
                _context.Add(session);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index", "Configurations"));
            }
            return(View(session));
        }