Beispiel #1
0
        public async Task LoadDataAsync()
        {
            if (loadDataActive == false)
            {
                var handled = false;

                loadDataActive = true;
                PrepareLoadDataArgs();
                BeforeLoadData(ref handled);
                if (handled == false)
                {
                    EditModel ??= new TModel();
                    AdapterAccess.SessionToken = ModelPage.AuthorizationSession.Token;
                    if (Id == 0)
                    {
                        var entity = await AdapterAccess.CreateAsync().ConfigureAwait(false);

                        EditModel.CopyProperties(entity);
                    }
                    else
                    {
                        var entity = await AdapterAccess.GetByIdAsync(Id).ConfigureAwait(false);

                        EditModel.CopyProperties(entity);
                    }
                }
                AfterLoadData();
                loadDataActive = false;
            }
        }
Beispiel #2
0
        public virtual async Task UpdateModelAsync(TModel model)
        {
            var handled = false;

            BeforeUpdateModel(model, ref handled);
            if (handled == false)
            {
                ValidateModel(model);
                var curItem = await AdapterAccess.UpdateAsync(model).ConfigureAwait(false);

                model.CopyProperties(curItem);
                UpdateReferences(model);
            }
            AfterUpdateModel(model);
        }