Exemplo n.º 1
0
        public async Task <IActionResult> PutEmbroideric(long id, Embroideric embroideric)
        {
            var num = _context.Embroiderics.Where(e => e.Num == embroideric.Num).FirstOrDefault();

            if (num == null)
            {
                if (id != embroideric.Id)
                {
                    return(BadRequest());
                }

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

                try
                {
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EmbroidericExists(id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
            }
            return(NoContent());
        }
Exemplo n.º 2
0
        public async Task <ActionResult <Embroideric> > PostEmbroideric(Embroideric embroideric)
        {
            var num   = _context.Embroiderics.Where(e => e.Num == embroideric.Num).FirstOrDefault();
            var image = _context.Embroiderics.Where(e => e.Image == embroideric.Image).FirstOrDefault();

            if (num == null && image == null)
            {
                _context.Embroiderics.Add(embroideric);
                await _context.SaveChangesAsync();
            }
            return(CreatedAtAction("GetEmbroideric", new { id = embroideric.Id }, embroideric));
        }