public static List <ProxySOVCovenant> ConvertToSOVCovenant(IEnumerable <new_covenants> covenantList)
        {
            List <ProxySOVCovenant> nsos = new List <ProxySOVCovenant>();

            foreach (var c in covenantList)
            {
                ProxySOVCovenant coventant = SingleConvertToSOVCovenant(c);
                nsos.Add(coventant);
            }
            return(nsos);
        }
        public static ProxySOVCovenant SingleConvertToSOVCovenant(new_covenants covenant)
        {
            ProxySOVCovenant proxyCovenant = new ProxySOVCovenant();

            proxyCovenant.CovenantDescription = covenant.new_CovenantDescription;
            proxyCovenant.CovenantID          = covenant.new_covenantsId != null ? covenant.new_covenantsId.Value : Guid.Empty;
            proxyCovenant.Name     = covenant.new_name;
            proxyCovenant.ParentID = (covenant.new_opportunity_new_covenants != null) ? covenant.new_opportunity_new_covenants.Id : Guid.Empty;
            //"__bo4200"
            proxyCovenant.ParentIDString     = string.Format("{0}{1}", string.Empty, proxyCovenant.ParentID.ToString());
            proxyCovenant.ID                 = covenant.Id;
            proxyCovenant.EffectiveStartDate = covenant.new_EffectiveStartDate;
            proxyCovenant.EffectiveEndDate   = covenant.new_EffectiveEndDate;
            proxyCovenant.CovenantType       = EnsureValueFromOptionSet(covenant, "new_covenanttype");
            proxyCovenant.DueDate            = covenant.new_DueDate;
            proxyCovenant.CompliedDate       = covenant.new_CompiledDate;
            proxyCovenant.Rating             = covenant.new_Rating;
            proxyCovenant.Remarks            = covenant.new_Remarks; //EnsureValueFromOptionSet(covenant, "new_remarks");
            proxyCovenant.ParagraphNo        = covenant.new_ParagraphNo;
            proxyCovenant.AgreementSectionNo = covenant.new_AgreementSectionNo;


            return(proxyCovenant);
        }
        public static ProxySOVCovenant SingleConvertToSOVCovenant(new_covenants covenant)
        {
            ProxySOVCovenant proxyCovenant = new ProxySOVCovenant();
            proxyCovenant.CovenantDescription = covenant.new_CovenantDescription;
            proxyCovenant.CovenantID = covenant.new_covenantsId != null ? covenant.new_covenantsId.Value : Guid.Empty;
            proxyCovenant.Name = covenant.new_name;
            proxyCovenant.ParentID = (covenant.new_opportunity_new_covenants != null) ? covenant.new_opportunity_new_covenants.Id : Guid.Empty;
            //"__bo4200"
            proxyCovenant.ParentIDString = string.Format("{0}{1}", string.Empty, proxyCovenant.ParentID.ToString());
            proxyCovenant.ID = covenant.Id;
            proxyCovenant.EffectiveStartDate = covenant.new_EffectiveStartDate;
            proxyCovenant.EffectiveEndDate = covenant.new_EffectiveEndDate;
            proxyCovenant.CovenantType = EnsureValueFromOptionSet(covenant,"new_covenanttype");
            proxyCovenant.DueDate = covenant.new_DueDate;
            proxyCovenant.CompliedDate = covenant.new_CompiledDate;
            proxyCovenant.Rating = covenant.new_Rating;
            proxyCovenant.Remarks = covenant.new_Remarks; //EnsureValueFromOptionSet(covenant, "new_remarks");
            proxyCovenant.ParagraphNo = covenant.new_ParagraphNo;
            proxyCovenant.AgreementSectionNo = covenant.new_AgreementSectionNo;

            return proxyCovenant;
        }
        public void UpdateSOVCovenant(ProxySOVCovenant covenant)
        {
            CacheHelper.ClearCache();
            //using (Xrm.XrmServiceContext context = new Xrm.XrmServiceContext("Xrm"))
            //{
            var c = (from s in this.xrm.new_covenantsSet
                     where s.Id == covenant.ID
                     select s).FirstOrDefault();
            if (c != null)
            {
                c.new_CompiledDate = covenant.CompliedDate;
                c.new_Rating = covenant.Rating;
                //c.new_Remarks = covenant.Remarks;
                c.new_ParagraphNo = covenant.ParagraphNo;
                c.new_AgreementSectionNo = covenant.AgreementSectionNo;

                this.xrm.UpdateObject(c);
                this.xrm.SaveChanges();
            }
            //}
        }