Пример #1
0
        public async Task <IActionResult> AddDrugs([FromBody] DrugDTO drugDTO)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            if (drugDTO == null)
            {
                return(BadRequest("Wrong data supplied"));
            }

            var drug = mapper.Map <DrugDTO, Drug>(drugDTO);

            if (await drugRepository.AddDrugAsync(drug))
            {
                return(Ok("Success"));
            }
            return(BadRequest("Drug already exist !!!!"));
        }