public async Task <IActionResult> UpdatePlannedPurchase(long purchaseId, PlannedPurchase purchaseToUpdate)
        {
            if (purchaseToUpdate == null)
            {
                return(BadRequest("You must provide a PlannedPurchase to update"));
            }

            if (purchaseId == purchaseToUpdate.PlannedPurchase_Id)
            {
                return(BadRequest("A matching purchase ID must be provided"));
            }

            PlannedPurchaseDTO checkPurchase = await plannedPurchaseRepository.GetPlannedPurchaseByIdAsync(purchaseId);

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

            await plannedPurchaseRepository.UpdatePlannedPurchaseAsync(dtoMapper.Map <PlannedPurchaseDTO>(purchaseToUpdate));

            return(Ok());
        }
Esempio n. 2
0
        public void UpdatePlannedPurchaseAsync_NullParameterThrows()
        {
            repository = new PlannedPurchaseRepository(context);

            Assert.ThrowsAsync <ArgumentNullException>(() => repository.UpdatePlannedPurchaseAsync(null));
        }