Example #1
0
        public async Task <IActionResult> Post([FromBody] ExternalGrid extgrid)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.ExternalGrids.Add(extgrid);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (ExtGridExists(extgrid.ID))
                {
                    return(new StatusCodeResult(StatusCodes.Status409Conflict));
                }
                else
                {
                    throw;
                }
            }
            return(CreatedAtAction("Get", new { id = extgrid.ID }, extgrid));
        }
Example #2
0
        public async Task <IActionResult> Put([FromRoute] int id, [FromBody] ExternalGrid extgrid)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != extgrid.ID)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Example #3
0
        public async Task <IActionResult> Delete([FromRoute] int id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            ExternalGrid extgrid = await _context.ExternalGrids.SingleOrDefaultAsync(m => m.ID == id);

            if (extgrid == null)
            {
                return(NotFound());
            }

            _context.ExternalGrids.Remove(extgrid);
            await _context.SaveChangesAsync();

            return(Ok(extgrid));
        }