예제 #1
0
        public async Task <IActionResult> PutMedicine([FromRoute] int id, [FromBody] Medicine medicine)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != medicine.Id)
            {
                return(BadRequest());
            }

            _medicineRepository.Update(medicine);

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

            return(Ok(medicine));
        }
예제 #2
0
        public bool MedicineExists(int id)
        {
            var medicine = _medicineRep.MedicineExists(id);

            return(medicine);
        }