Ejemplo n.º 1
0
        public async Task <IActionResult> PutClass([FromQuery] string secret, int id, Class @class)
        {
            if (!AuthHelper.validate(secret))
            {
                return(Unauthorized());
            }

            if (id != @class.ClassID)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> PutStudent(string id, Student student)
        {
            if (id != student.Barcode)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> PutUnit(int id, Unit unit)
        {
            if (id != unit.ClusterID)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> PutLabel(int id, Label label)
        {
            if (id != label.ClassID)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }