public async Task <IActionResult> PutStudentsClasses(int id, StudentsClasses studentsClasses)
        {
            if (id != studentsClasses.Id)
            {
                return(BadRequest());
            }

            _context.Entry(studentsClasses).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!StudentsClassesExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemplo n.º 2
0
        public async Task <IActionResult> PutGroup(int id, Group @group)
        {
            if (id != @group.Id)
            {
                return(BadRequest());
            }

            _context.Entry(@group).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!GroupExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IActionResult> PutTeachersDisciplines(int id, TeachersDisciplines teachersDisciplines)
        {
            if (id != teachersDisciplines.DisciplineId)
            {
                return(BadRequest());
            }

            _context.Entry(teachersDisciplines).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TeachersDisciplinesExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemplo n.º 4
0
        public async Task <IActionResult> PutDiscipline(int id, Discipline discipline)
        {
            if (id != discipline.Id)
            {
                return(BadRequest());
            }

            _context.Entry(discipline).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DisciplineExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <ActionResult <Teacher> > PostTeacher(TeacherCred teacher)
        {
            var rnd        = new Random();
            var salt       = SecurityManager.GenerateSalt(rnd.Next() % 12 + 8);
            var iterations = rnd.Next() % 12 + 1;
            var hash       = SecurityManager.GetHash(teacher.Password, salt, iterations);

            teacher.Salt       = salt;
            teacher.Iterations = iterations;
            teacher.Password   = hash;

            _context.Add(teacher);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetTeacher", new { id = teacher.Id }, teacher));
        }
Exemplo n.º 6
0
        public async Task <IActionResult> PutGroupsDisciplines(int id, GroupsDisciplines groupsDisciplines)
        {
            _context.Entry(groupsDisciplines).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!GroupsDisciplinesExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }