Example #1
0
        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());
        }
Example #2
0
        public async Task <ActionResult <Medcines> > PostMedcines(Medcines medcines)
        {
            _context.Medcines.Add(medcines);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetMedcines", new { id = medcines.id }, medcines));
        }
Example #3
0
        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));
            }
        }