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)); }
public bool MedicineExists(int id) { var medicine = _medicineRep.MedicineExists(id); return(medicine); }