Ejemplo n.º 1
0
        private async Task UpdateFarmAsync(FarmData farmData, Farm dbFarm, bool forceUpdate)
        {
            if (IsDifferent(farmData, dbFarm) || forceUpdate)
            {
                // Require a minimum of a name
                if (string.IsNullOrWhiteSpace(farmData.Name))
                {
                    return;
                }

                Logger.LogInformation($"Updating farm \"{farmData.Name}\"");

                var updatedFarm = await FarmDataToFarmService.MakeFarmFromFarmDataAsync(farmData);

                // Mark it as an update of the existing db record
                updatedFarm.VersionNumber = dbFarm.VersionNumber;

                await FarmRepository.UpdateAsync(updatedFarm);
            }
        }