예제 #1
0
        public Task <Guid> UpdateForecastAsync(DbWeatherForecast record)
        {
            var rec = this.Forecasts.FirstOrDefault(item => item.ID.Equals(record.ID));

            if (rec != default)
            {
                this.Forecasts.Remove(rec);
            }
            this.Forecasts.Add(record);
            return(Task.FromResult(record.ID));
        }
예제 #2
0
        public Task <Guid> AddForecastAsync(DbWeatherForecast record)
        {
            var id = Guid.NewGuid();

            if (record.ID.Equals(Guid.Empty))
            {
                var recdata = record.AsRecordCollection;
                recdata.SetField(DbWeatherForecast.__ID.FieldName, id);
                record = DbWeatherForecast.FromRecordCollection(recdata);
            }
            else
            {
                var rec = this.Forecasts.FirstOrDefault(item => item.ID.Equals(record.ID));
                if (rec != default)
                {
                    return(Task.FromResult(Guid.Empty));
                }
            }
            this.Forecasts.Add(record);
            return(Task.FromResult(id));
        }