Exemple #1
0
        public void ProcessListError(List <TModel> Entities)
        {
            if (Entities == null)
            {
                return;
            }
            EntityList = Entities;
            IsSearched = true;
            bool          haserror = false;
            List <string> keys     = new List <string>();

            if (string.IsNullOrEmpty(DetailGridPrix) == false)
            {
                foreach (var item in MSD.Keys)
                {
                    if (item.StartsWith(DetailGridPrix))
                    {
                        var errors = MSD[item];
                        if (errors.Count > 0)
                        {
                            Regex r = new Regex($"{DetailGridPrix}\\[(.*?)\\]");
                            try
                            {
                                if (int.TryParse(r.Match(item).Groups[1].Value, out int index))
                                {
                                    EntityList[index].BatchError = errors.Select(x => x.ErrorMessage).ToSpratedString();
                                    keys.Add(item);
                                    haserror = true;
                                }
                            }
                            catch { }
                        }
                    }
                }
                foreach (var item in keys)
                {
                    MSD.RemoveModelError(item);
                }
                if (haserror)
                {
                    AddErrorColumn();
                }
            }
        }