Exemplo n.º 1
0
        public async Task OnInputValueChanged(IMField pField, IMPropertyInfo pPropertyInfo, object pNewValue)
        {
            ChangedValues.Add(pPropertyInfo);

            if (OnValueChanged.HasDelegate)
            {
                await OnValueChanged.InvokeAsync(new MFormValueChangedArgs <T>(pField, pPropertyInfo, pNewValue, Model));
            }
        }
Exemplo n.º 2
0
        public ChangedValues GetLastInsert()
        {
            using (var context = new DataContext())
            {
                var values = new ChangedValues();

                values.TotalCure    = context.CountryDetails.OrderBy(x => x.Id).Select(x => x.Cure).LastOrDefault();
                values.TotalDeaths  = context.CountryDetails.OrderBy(x => x.Id).Select(x => x.Death).LastOrDefault();
                values.TotalPatient = context.CountryDetails.OrderBy(x => x.Id).Select(x => x.Patient).LastOrDefault();
                values.Total        = values.TotalCure + values.TotalDeaths + values.TotalPatient;


                return(values);
            }
        }
Exemplo n.º 3
0
        public async Task OnInputValueChanged(IMField pField, IMPropertyInfo pPropertyInfo, object pNewValue)
        {
            if (!ChangedValues.Contains(pPropertyInfo))
            {
                ChangedValues.Add(pPropertyInfo);
            }

            if (OnValueChanged.HasDelegate)
            {
                await OnValueChanged.InvokeAsync(new MFormValueChangedArgs <T>(pField, pPropertyInfo, pNewValue, Model));
            }

            if (mEditContext != null && pField is IMPropertyField propertyField)
            {
                mEditContext.NotifyFieldChanged(mEditContext.Field(propertyField.Property));
            }
        }
Exemplo n.º 4
0
        private async Task <bool> CascadedFormContext_OnFormSubmit(object sender, MFormContainerContextSubmitArgs e)
        {
            // Console.WriteLine("FormContextSubmit: " + typeof(T));

            var isValid = mEditContext.Validate(); // This will likely become ValidateAsync later

            if (!isValid)
            {
                Console.WriteLine(typeof(T) + ": Not valid");

                //       if (ContainerContext != null)
                //           throw new UserMessageException(L["Please check all forms. There is at least one validation error!"]);

                return(false);
            }

            Dictionary <string, object> changedDict = new Dictionary <string, object>();

            if (HasUnsavedChanges)
            {
                foreach (var entry in ChangedValues)
                {
                    var fullname = entry.GetFullName();

                    if (changedDict.ContainsKey(fullname))
                    {
                        continue;
                    }

                    object value = entry.GetValue(Model);
                    changedDict.Add(fullname, value);
                }

                ChangedValues.Clear();
            }

            if (OnValidSubmit.HasDelegate)
            {
                await OnValidSubmit.InvokeAsync(new MFormSubmitArgs(mEditContext, changedDict, Model, e.UserInterated));
            }

            return(true);
        }
Exemplo n.º 5
0
        private void CascadedFormContext_OnFormSubmit(object sender, MFormContainerContextSubmitArgs e)
        {
            // Console.WriteLine("FormContextSubmit: " + typeof(T));

            var isValid = mEditContext.Validate(); // This will likely become ValidateAsync later

            if (!isValid)
            {
                if (ContainerContext != null)
                {
                    throw new UserMessageException("Please check the values. There is at least one validation error!");
                }
                Console.WriteLine(typeof(T) + ": Not valid!");
                return;
            }

            Dictionary <string, object> changedDict = new Dictionary <string, object>();

            if (HasUnsavedChanges)
            {
                foreach (var entry in ChangedValues)
                {
                    string fieldname = entry.FieldName;

                    if (changedDict.ContainsKey(fieldname))
                    {
                        continue;
                    }

                    //01.08.2020 entry.Model is an old wrong version of the model in client side
                    object value = ReflectionHelper.GetPropertyValue(Model, entry.FieldName);
                    changedDict.Add(fieldname, value);
                }

                ChangedValues.Clear();
            }

            if (OnValidSubmit.HasDelegate)
            {
                var task = OnValidSubmit.InvokeAsync(new MFormSubmitArgs(mEditContext, changedDict, Model, e.UserInterated));
                task.Wait();
            }
        }
 public void                                         raiseValuesChanged()
 {
     ChangedValues?.Invoke(this, EventArgs.Empty);
 }