예제 #1
0
        public async Task <IActionResult> PutStateLocalGovernment(short id, StateLocalGovernment stateLocalGovernment)
        {
            if (id != stateLocalGovernment.StateLocalGovernmentId)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
예제 #2
0
        public async Task <ActionResult <StateLocalGovernment> > PostStateLocalGovernment(StateLocalGovernment stateLocalGovernment)
        {
            _context.StateLocalGovernment.Add(stateLocalGovernment);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (StateLocalGovernmentExists(stateLocalGovernment.StateLocalGovernmentId))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("GetStateLocalGovernment", new { id = stateLocalGovernment.StateLocalGovernmentId }, stateLocalGovernment));
        }