Example #1
0
        public async Task <IActionResult> Post([FromBody] Attribute attribute)
        {
            context.Attributes.Add(attribute);
            var changes = await context.SaveChangesAsync();

            if (changes > 0)
            {
                return(Ok());
            }
            else
            {
                return(NotFound());
            }
        }
Example #2
0
        public async Task <IActionResult> Put(int id, [FromBody] Attribute attribute)
        {
            attribute.ID = id;
            context.Update(attribute);
            var changes = await context.SaveChangesAsync();

            if (changes > 0)
            {
                return(Ok());
            }
            else
            {
                return(NotFound());
            }
        }
Example #3
0
        public async Task <IActionResult> Delete(int id)
        {
            var attr = new Attribute
            {
                ID = id,
            };

            context.Attributes.Remove(attr);
            var changes = await context.SaveChangesAsync();

            if (changes > 0)
            {
                return(Ok());
            }
            else
            {
                return(NotFound());
            }
        }