Ejemplo n.º 1
0
        internal static List <Variance> DetailedCompare(UpdateUser UserUpdateModel, SaveUser UserSavedModel)
        {
            List <Variance> variances = new List <Variance>();
            //var prop = UserUpdateModel.GetType().GetProperties();
            //var prop1 = UserSavedModel.GetType().GetProperties().Select(x => x.Name);
            //prop = prop.Where(x => prop1.Contains(x.Name)).ToArray();

            Type type_s = UserSavedModel.GetType();

            PropertyInfo[] properties_s = type_s.GetProperties();
            // bool hasMetaDataAttribute_s = false;


            //object item;
            Type type_u = UserUpdateModel.GetType();

            PropertyInfo[] properties_u           = type_u.GetProperties();
            bool           hasMetaDataAttribute_u = false;

            foreach (PropertyInfo f in properties_u)
            {
                string   displayName = GetDisplayName(type_u, f, hasMetaDataAttribute_u);
                Variance v           = new Variance();
                v.FieldName = displayName;

                //if (f.Name == "RoleName")
                //    v.FieldName = "Role Name";
                //else if (f.Name == "Marital")
                //    v.FieldName = " Marital Status";
                //else
                //    v.FieldName = f.Name;

                v.UserUpdateValue = UserUpdateModel.GetType().GetProperty(f.Name).GetValue(UserUpdateModel, null);
                v.UserSaveValue   = UserSavedModel.GetType().GetProperty(f.Name).GetValue(UserSavedModel, null);
                if (v.UserUpdateValue != null && v.UserSaveValue != null)
                {
                    if (!v.UserUpdateValue.ToString().Equals(v.UserSaveValue.ToString()))
                    {
                        variances.Add(v);
                    }
                }
                else
                {
                    if (v.UserUpdateValue == null && v.UserSaveValue == null)
                    {
                    }
                    else
                    {
                        variances.Add(v);
                    }
                }
            }

            //Commented to avoid Content Repeat while sending mail

            //    Type type_s = UserSavedModel.GetType();
            //    PropertyInfo[] properties_s = type_s.GetProperties();
            //    bool hasMetaDataAttribute_s = false;
            //    foreach (PropertyInfo f in properties_s)
            //    {
            //        string displayName = GetDisplayName(type_s, f, hasMetaDataAttribute_s);

            //        Variance v = new Variance();

            //        v.FieldName = displayName;
            //        //if (f.Name == "RoleName")
            //        //    v.FieldName = "Role Name";
            //        //else if (f.Name == "Marital")
            //        //    v.FieldName = " Marital Status";
            //        //else
            //        //    v.FieldName = f.Name;

            //        v.UserUpdateValue = UserUpdateModel.GetType().GetProperty(f.Name).GetValue(UserUpdateModel, null);
            //        v.UserSaveValue = UserSavedModel.GetType().GetProperty(f.Name).GetValue(UserSavedModel, null);
            //        if (v.UserUpdateValue != null && v.UserSaveValue != null)
            //        {
            //            if (!v.UserUpdateValue.ToString().Equals(v.UserSaveValue.ToString()))
            //                variances.Add(v);
            //        }
            //        else
            //        {
            //            if (v.UserUpdateValue == null && v.UserSaveValue == null)
            //            {
            //            }
            //            else
            //            {
            //                variances.Add(v);
            //            }
            //        }

            //    }
            return(variances);
        }
Ejemplo n.º 2
0
        internal static List <Variance> DetailedCompare(UpdatePaymentStructure updated, PaymentStructure saved)
        {
            List <Variance> variances = new List <Variance>();
            var             prop      = updated.GetType().GetProperties();
            var             prop1     = saved.GetType().GetProperties().Select(x => x.Name);

            prop = prop.Where(x => prop1.Contains(x.Name)).ToArray();
            foreach (PropertyInfo f in prop)
            {
                Variance v = new Variance();

                if (f.Name == "RoleName")
                {
                    v.FieldName = "Role Name";
                }
                else if (f.Name == "Marital")
                {
                    v.FieldName = " Marital Status";
                }
                else
                {
                    v.FieldName = f.Name;
                }

                v.UserUpdateValue = updated.GetType().GetProperty(f.Name).GetValue(updated, null);
                v.UserSaveValue   = saved.GetType().GetProperty(f.Name).GetValue(saved, null);
                //if (f.Name == "TotalTermAmount" || f.Name == "TotalTermDueDate")
                //{
                //    if (updated.TotalTermAmount != null && updated.TotalTermDueDate != null &&
                //        saved.TotalTermAmount != null && saved.TotalTermDueDate != null)
                //    {
                //        string[] old = updated.TermAmount.ToArray();
                //        string[] upda = saved.TermAmount.ToArray();
                //        foreach (var a in old)
                //        {
                //            if (!(upda).Contains(a))
                //            {
                //                variances.Add(v);
                //            }
                //        }
                //    }
                //}

                if (v.UserUpdateValue != null && v.UserSaveValue != null)
                {
                    if (!v.UserUpdateValue.ToString().SequenceEqual(v.UserSaveValue.ToString()))
                    {
                        //if (!v.UserUpdateValue.ToString().Equals(v.UserSaveValue.ToString()))
                        variances.Add(v);
                    }
                }

                else
                {
                    if (v.UserUpdateValue == null && v.UserSaveValue == null)
                    {
                    }
                    else
                    {
                        variances.Add(v);
                    }
                }
            }
            return(variances);
        }