Beispiel #1
0
        public UpdatePharmacyInventoryResponse GetFakeUpdatePharmacyInventoryResponse_QuantityOnHandNonZero()
        {
            var fake = new UpdatePharmacyInventoryResponse()
            {
                Message = $"Record with Id: 1 sucessfully updated."
            };

            return(fake);
        }
Beispiel #2
0
        public async Task <UpdatePharmacyInventoryResponse> Put([FromBody] UpdatePharmacyInventoryRequest request, long id = 0)
        {
            UpdatePharmacyInventoryResponse updatePharmacyInventoryResponse;

            try
            {
                if (id <= 0L)
                {
                    throw new Exception("Id of item must be greater than zero.");
                }

                if (request.QuantityOnHand <= 0)
                {
                    throw new Exception($"QuantityOnHand must be non zero.");
                }

                var resp = await _domainService.UpdatePharmacyInventory(id, request);

                if (resp)
                {
                    updatePharmacyInventoryResponse = new UpdatePharmacyInventoryResponse()
                    {
                        Message = $"Record with Id: {id} sucessfully updated."
                    };
                }
                else
                {
                    throw new ProblemDetailsException(StatusCodes.Status404NotFound, $"Record with Id: {id} does not exist.");
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

            return(updatePharmacyInventoryResponse);
        }