Beispiel #1
0
        /// <summary>
        /// Updates the entity
        /// </summary>
        /// <param name="id"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public async Task <T> UpdateAsync(Guid id, T value)
        {
            var existing = await GetAsync(id);

            if (existing != null)
            {
                if (existing.Version == value.Version)
                {
                    context.Entry(existing).CurrentValues.SetValues(value);

                    await CompleteUpdateAsync(existing, value);

                    await context.CommitAsync();
                }
                else
                {
                    errorService.Value.ShowError("L'enregistrement n'a pas été enregistré car il n'était pas a jour.");
                    //throw new SyncConflictVersionException<T>(value, existing);
                }
                return(existing);
            }
            else
            {
                return(await AddAsync(value));
            }
        }