public UpdateResult <WeightMeasurement> Update(WeightMeasurement measurement, List <string> updateMask) { if (measurement == null || measurement.Id == Guid.Empty) { return(UpdateResult <WeightMeasurement> .BadRequest("Weight measurement failed to be created before storage.")); } if (updateMask.Contains("unit", StringComparer.InvariantCultureIgnoreCase) && measurement.Unit == WeightMeasurement.Units.None) { return(UpdateResult <WeightMeasurement> .BadRequest("Invalid weight unit provided. Valid values are: " + Enum <WeightMeasurement.Units> .GetValuesAsCSV())); } if (updateMask.Contains("weight", StringComparer.InvariantCultureIgnoreCase) && measurement.Weight < 0) { return(UpdateResult <WeightMeasurement> .BadRequest("Weight must be a non-negative value.")); } try { if (_store.Update(measurement, updateMask)) { var artifact = _store.Read(measurement.Id); return(UpdateResult <WeightMeasurement> .Ok(artifact)); } else { return(UpdateResult <WeightMeasurement> .Conflict("Unable to update the measurement. Please try again.")); } } catch (Exception ex) { return(UpdateResult <WeightMeasurement> .HandleException(ex)); } }