public IActionResult Delete(int id)
        {
            Drugs doctor = _drugRepository.GetDrugsbyId(id);

            _drugRepository.Delete(doctor);
            return(RedirectToAction("CreateByStore", "Drugs", new
            {
                Id = doctor.StoresId
            }));
            //return RedirectToAction("CreateByStore");
        }
示例#2
0
        public async Task <ActionResult <Drug> > DeleteDrug(int id)
        {
            var itExists = await _drugRepository.ItExists(id);

            if (!itExists)
            {
                return(NotFound());
            }
            var drug = await _drugRepository.FindById(id);

            var isSuccess = await _drugRepository.Delete(drug);

            if (!isSuccess)
            {
                return(InternalError($"Drug delete failed"));
            }
            return(NoContent());
        }
        public async Task <IActionResult> DeleteDrug([FromRoute] int id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var drug = await _drugRepository.FindAsync(id);

            if (drug == null)
            {
                return(NotFound());
            }

            _drugRepository.Delete(drug);
            await _drugRepository.SaveChangesAsync();

            return(Ok(drug));
        }
 public void Delete(Drug entity)
 {
     _repository.Delete(entity);
 }