Exemplo n.º 1
0
        public async Task <IActionResult> PutType(int id, Type @type)
        {
            if (id != @type.ID)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Exemplo n.º 2
0
        public async Task <IActionResult> ActiveType(int id)
        {
            Type b = _context.Types.FirstOrDefault(a => a.ID == id && a.Active == false);

            if (b != null)
            {
                b.Active = true;
            }
            else
            {
                b = null;
            }

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

            return(NoContent());
        }
Exemplo n.º 3
0
        public async Task <ActionResult <Type> > PostType(Type @type)
        {
            _context.Types.Add(@type);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetType", new { id = @type.ID }, @type));
        }