public async Task <IActionResult> OnPostEditAsync()
        {
            if (ModelState.IsValid)
            {
                try
                {
                    await _measureController.UpdateMeasureAsync(toEdit);

                    return(RedirectToPage("Index"));
                }
                catch (Exception)
                {
                    return(RedirectToPage("/Error"));
                }
            }
            return(Page());
        }
        public async Task UpdateMeasureAsync_Should_Update()
        {
            //Arrange
            List <Measure> mockMeasureDB = GetMeasures();
            Measure        toUpdate      = new Measure {
                Id = 1, Name = "gram"
            };

            _mockRepository.Setup(r => r.GetByIdAsync <Measure>(toUpdate.Id)).ReturnsAsync((int a) => mockMeasureDB.FirstOrDefault(x => x.Id == a));
            _mockRepository.Setup(r => r.UpdateAsync <Measure>(It.Is <Measure>(entity => entity.Id == toUpdate.Id)))
            .Callback((Measure recipe) =>
            {
                recipe.Name = toUpdate.Name;
            });
            //Act
            await _measureController.UpdateMeasureAsync(toUpdate);

            //Assert
            var retrieved = mockMeasureDB.FirstOrDefault(x => x.Id == toUpdate.Id);

            _mockRepository.Verify(r => r.GetByIdAsync <Measure>(toUpdate.Id), Times.Once);
            _mockRepository.Verify(r => r.UpdateAsync <Measure>(It.Is <Measure>(entity => entity.Id == toUpdate.Id)), Times.Once);
            Assert.Contains("gr", retrieved.Name);
        }