Esempio n. 1
0
        private async Task DeleteFormAsync()
        {
            var result = await requestManager.DeleteAsync($"{RoutingConstants.FormRoute}/{SelectedForm.IdForm}");

            if (result.IsError)
            {
                notificationManager.Alert(result.ErrorMessage, result.IsFatalError);
                await InitializeAsync(false);
            }
            else
            {
                notificationManager.ToastAlert(string.Format(Resources.FormDeleted, SelectedForm.FormNr));

                var form = FormModels.FirstOrDefault(x => x.IdForm == selectedForm.IdForm);
                if (form != null)
                {
                    FormModels.Remove(form);
                }

                UpdateHeaderView();
            }
        }
Esempio n. 2
0
        private async Task UpdateGridAsync(UpdateFormEventArgs updatedFormArgs)
        {
            Guid callingOwnerId = updatedFormArgs.OwnerChooseModel.Id;
            Guid?formId         = updatedFormArgs.FormId;

            string path = string.Format("{0}/{1}", RoutingConstants.FormRoute, formId.ToString());

            try
            {
                BusyIndicator.BlockUI();
                var result = await requestManager.GetAsync <FormModel>(path);

                if (result.Data == null || result.IsError)
                {
                    await InitializeAsync(true);
                }
                else
                {
                    FormModel resultForm = result.Data;
                    if (updatedFormArgs.IsNew)
                    {
                        bool scrollToFirst = false;
                        if (OwnerChooseModel != null)
                        {
                            if (OwnerChooseModel.Id == callingOwnerId)
                            {
                                FormModels.Add(resultForm);
                                SelectedForm = FormModels.FirstOrDefault(x => x.IdForm.Equals(resultForm.IdForm));
                            }
                            else
                            {
                                scrollToFirst = true;
                            }
                        }
                        else
                        {
                            FormModels.Add(resultForm);
                            SelectedForm = FormModels.FirstOrDefault(x => x.IdForm.Equals(resultForm.IdForm));
                        }

                        ScrollOrRefreshGrid(this, new CleanFilterEventArgs()
                        {
                            ScrollToFirst = scrollToFirst
                        });
                    }
                    else
                    {
                        FormModel editedFormModel = FormModels.FirstOrDefault(x => x.IdForm == formId);
                        if (editedFormModel != null)
                        {
                            if (OwnerChooseModel != null && callingOwnerId != OwnerChooseModel.Id)
                            {
                                if (FormModels.Any())
                                {
                                    FormModels.Remove(editedFormModel);
                                }
                            }
                            else
                            {
                                int editedFormModelIndex = FormModels.IndexOf(editedFormModel);
                                if (editedFormModelIndex != -1)
                                {
                                    FormModels[editedFormModelIndex] = resultForm;
                                }
                            }
                        }
                    }
                }
            }
            finally
            {
                BusyIndicator.UnblockUI();
            }
        }