Esempio n. 1
0
        public async Task <bool> UpdatePharmacyInventory(long id, UpdatePharmacyInventoryRequest updatePharmacyInventoryRequest)
        {
            bool resp;

            try
            {
                var itemExists = await CheckIfItemExists(updatePharmacyInventoryRequest.IdItem);

                if (itemExists)
                {
                    var pharmacyExists = await CheckIfPharmacyExists(updatePharmacyInventoryRequest.IdPharmacy);

                    if (pharmacyExists)
                    {
                        var pharmacyInventoryTable = _mapper.Map <PharmacyInventoryTable>(updatePharmacyInventoryRequest);
                        pharmacyInventoryTable.Id = id;
                        resp = await UpdatePharmacyInventoryTable(pharmacyInventoryTable);
                    }
                    else
                    {
                        throw new Exception("Pharmacy doesn't exists.");
                    }
                }
                else
                {
                    throw new Exception("Item doesn't exists.");
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

            return(resp);
        }
Esempio n. 2
0
        public UpdatePharmacyInventoryRequest GetFakeUpdatePharmacyInventoryRequest_QuantityOnHandNonZero()
        {
            var fake = new UpdatePharmacyInventoryRequest()
            {
                IdItem               = 1,
                IdPharmacy           = 1,
                QuantityOnHand       = 10,
                UnitPrice            = 65.62M,
                ReorderQuantity      = 10,
                SellingUnitOfMeasure = "M3"
            };

            return(fake);
        }
Esempio n. 3
0
        public UpdatePharmacyInventoryRequest GetFakeUpdatePharmacyInventoryRequest_OnlyIf_Item_And_Pharmacy_Exists_Success()
        {
            var fake = new UpdatePharmacyInventoryRequest()
            {
                IdPharmacy           = 1,
                IdItem               = 1,
                QuantityOnHand       = 12,
                UnitPrice            = 65.62M,
                ReorderQuantity      = 10,
                SellingUnitOfMeasure = "M3"
            };

            return(fake);
        }
Esempio n. 4
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);
        }
Esempio n. 5
0
 public async Task <bool> UpdatePharmacyInventory(long id, UpdatePharmacyInventoryRequest updatePharmacyInventoryRequest)
 {
     return(await Task.FromResult(true));
 }