public async Task UpdateFarmer()
        {
            _appInsightsService.LogEvent("farmers/update", "Updating selected farmer in local repository!");

            // Update the selected farmer
            if (CurrentFarmer != null)
            {
                await _farmerRepo.UpdateFarmer((FarmerModel)CurrentFarmer);
            }
        }
Exemplo n.º 2
0
        public async Task <IActionResult> UpdateFarmers(CreateorEditFarmer input)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    await _farmerRepository.UpdateFarmer(input);

                    return(Ok());
                }
                catch (Exception ex)
                {
                    if (ex.GetType().FullName == "Microsoft.EntityFrameworkCore.DbUpdateConcurrencyException")
                    {
                        return(NotFound());
                    }

                    return(BadRequest());
                }
            }

            return(BadRequest());
        }