public async Task <IActionResult> PutMedcines(int id, Medcines medcines) { if (id != medcines.id) { return(BadRequest()); } _context.Entry(medcines).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MedcinesExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <Medcines> > PostMedcines(Medcines medcines) { _context.Medcines.Add(medcines); await _context.SaveChangesAsync(); return(CreatedAtAction("GetMedcines", new { id = medcines.id }, medcines)); }
public async Task <ActionResult <Medcines> > PostMedcines(Medcines medcines) { try { _context.Medcines.Add(medcines); await _context.SaveChangesAsync(); return(CreatedAtAction("GetMedcines", new { id = medcines.id }, medcines)); } catch (Exception e) { return(BadRequest(e.Message)); } }