Beispiel #1
0
        public async Task <IActionResult> PutClazzAccount([FromRoute] string id, [FromBody] ClazzAccount clazzAccount)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            if (id != clazzAccount.ClazzId)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Beispiel #2
0
        public async Task <IActionResult> PostClazzAccount([FromBody] ClazzAccount clazzAccount)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.ClazzAccount.Add(clazzAccount);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (ClazzAccountExists(clazzAccount.ClazzId))
                {
                    return(new StatusCodeResult(StatusCodes.Status409Conflict));
                }
                else
                {
                    throw;
                }
            }
            return(CreatedAtAction("GetClazzAccount", new { id = clazzAccount.ClazzId }, clazzAccount));
        }