public IActionResult GetDispatchableDrugStock([FromRoute] int drugId, string location)
        {
            try
            {
                //Validating drugId and location
                if (drugId > 0 && (location.All(Char.IsLetter)))
                {
                    // Checking if drug with specific id is present.
                    var drug = _drugService.GetDispatchableDrugStock(drugId, location);

                    // Drug Id(drugId) and Location(location) recieved From other Api's.
                    if (drug == null)
                    {
                        return(NotFound("Drug with specified drugId and location is not available"));
                    }
                    return(Ok(drug));
                }
                else
                {
                    return(BadRequest());
                }
            }
            catch (Exception e)
            {
                return(BadRequest("Error occured from " + nameof(DrugsApiController.GetDispatchableDrugStock) + " Error Message " + e.Message));
            }
        }
Exemple #2
0
 public ActionResult <DispatchableDrugStockDTO> GetDispatchableDrugStock(int id, string location)
 {
     _log4net.Info("DrugMicroService : " + nameof(GetDispatchableDrugStock));
     if (id == 0 || location == null)
     {
         return(BadRequest("please give valid details"));
     }
     try
     {
         var result = _drugService.GetDispatchableDrugStock(id, location);
         if (result == null)
         {
             return(BadRequest("data not found"));
         }
         else
         {
             return(Ok(result));
         }
     }
     catch (Exception e)
     {
         _log4net.Error("Exception Occured : " + e.Message + " from " + nameof(GetDispatchableDrugStock));
         return(BadRequest("Exception Occured"));
     }
 }
Exemple #3
0
        public IActionResult GetDispatchableDrugStock(int drugId, string location)
        {
            try
            {
                _log4net.Info("Searched drug with DrugId " + drugId + " and Location " + location);

                //Validating drugId and location
                if (drugId > 0 && (location.All(Char.IsLetter)))
                {
                    // Checking if drug with specific id is present.
                    var drug = _drugService.GetDispatchableDrugStock(drugId, location);

                    // Drug Id(drugId) and Location(location) recieved From other Api's.
                    if (drug == null)
                    {
                        _log4net.Info("Drug with drugId -> " + drugId + " and Location -> " + location + " not available.");
                        return(NotFound("Drug with specified drugId and location is not available"));
                    }
                    return(Ok(drug));
                }
                else
                {
                    _log4net.Info("Invalid DrugId or location");
                    return(BadRequest());
                }
            }
            catch (Exception e)
            {
                _log4net.Error("Error occured from " + nameof(DrugsApiController.GetDispatchableDrugStock) + " Error Message " + e.Message);
                return(BadRequest("Error occured from " + nameof(DrugsApiController.GetDispatchableDrugStock) + " Error Message " + e.Message));
            }
        }
Exemple #4
0
        public ActionResult <DispatchableDrugStockDTO> Post(int id, string location)
        {
            if (id == 0 || location == null)
            {
                return(BadRequest("please give valid details"));
            }
            var result = _drugService.GetDispatchableDrugStock(id, location);

            if (result == null)
            {
                return(BadRequest("data not found"));
            }
            else
            {
                return(Ok(result));
            }
        }