public void UpdateNSOCovenant(ProxyNSOCovenant covenant)
        {
            CacheHelper.ClearCache();
            //using (Xrm.XrmServiceContext context = new Xrm.XrmServiceContext("Xrm"))
            //{
            var c = (from s in this.xrm.new_nsocovenantSet
                     where s.Id == covenant.ID
                     select s).FirstOrDefault();
            if (c != null)
            {
                //c.new_Status = covenant.Status;
                //c.new_CompliedWith = Convert.ToInt32(covenant.CompliedWith);

                //c.new_Description = covenant.CovenantDescription;
                //c.new_CovenantType = covenant.CovenantType;
                c.new_CompliedWith = covenant.CompliedWithID;
                c.new_Status = covenant.StatusID;
                c.new_DueDate = covenant.DueDate;
                //c.new_FrequencyofReview = covenant.FrequencyOfReview;
                //c.new_name = covenant.Name;
                //covenant.
                c.new_SubmissionDate = covenant.SubmissionDate;

                this.xrm.UpdateObject(c);
                this.xrm.SaveChanges();
            }
            //}
        }
        public static List <ProxyNSOCovenant> ConvertToNSOCovenant(IEnumerable <new_nsocovenant> list)
        {
            List <ProxyNSOCovenant> nsos = new List <ProxyNSOCovenant>();

            foreach (var c in list)
            {
                ProxyNSOCovenant cov = SingleConvertToNSOCovenant(c);
                nsos.Add(cov);
            }
            return(nsos);
        }
        public static ProxyNSOCovenant SingleConvertToNSOCovenant(new_nsocovenant nso)
        {
            ProxyNSOCovenant proxyCovenant = new ProxyNSOCovenant();

            proxyCovenant.CovenantDescription = nso.new_Description;
            proxyCovenant.CovenantID          = nso.new_nsocovenantId.Value;
            proxyCovenant.Name     = nso.new_name;
            proxyCovenant.ParentID = (nso.new_opportunity_new_nsocovenant != null) ? nso.new_opportunity_new_nsocovenant.OpportunityId.Value : Guid.Empty;
            //"__bo4200"
            proxyCovenant.ParentIDString = string.Format("{0}{1}", string.Empty, proxyCovenant.ParentID.ToString());
            proxyCovenant.ID             = nso.Id;


            /*
             * [DataMember]
             * public string CovenantType { get; set; }
             * [DataMember]
             * public string Reference { get; set; }
             * [DataMember]
             * public string FrequencyOfReview { get; set; }
             * [DataMember]
             * public string RemarksIssues { get; set; }
             * [DataMember]
             * public DateTime? DueDate { get; set; }
             * [DataMember]
             * public string CompliedWith { get; set; }
             * [DataMember]
             * public DateTime SubmissionDate { get; set; }
             * [DataMember]
             * public string Status { get; set; }
             */
            proxyCovenant.CovenantType      = EnsureValueFromOptionSet(nso, "new_type");
            proxyCovenant.Reference         = nso.new_Reference;
            proxyCovenant.FrequencyOfReview = EnsureValueFromOptionSet(nso, "new_frequencyofreview");
            proxyCovenant.RemarksIssues     = nso.new_RemarksIssues;
            proxyCovenant.DueDate           = nso.new_DueDate;
            proxyCovenant.CompliedWith      = EnsureValueFromOptionSet(nso, "new_compliedwith");
            proxyCovenant.CompliedWithID    = nso.new_CompliedWith;
            proxyCovenant.SubmissionDate    = nso.new_SubmissionDate;
            proxyCovenant.Status            = EnsureValueFromOptionSet(nso, "new_status");
            proxyCovenant.StatusID          = nso.new_Status;
            return(proxyCovenant);
        }
        public static ProxyNSOCovenant SingleConvertToNSOCovenant(new_nsocovenant nso)
        {
            ProxyNSOCovenant proxyCovenant = new ProxyNSOCovenant();
            proxyCovenant.CovenantDescription = nso.new_Description;
            proxyCovenant.CovenantID = nso.new_nsocovenantId.Value;
            proxyCovenant.Name = nso.new_name;
            proxyCovenant.ParentID = (nso.new_opportunity_new_nsocovenant != null) ? nso.new_opportunity_new_nsocovenant.OpportunityId.Value : Guid.Empty;
            //"__bo4200"
            proxyCovenant.ParentIDString = string.Format("{0}{1}", string.Empty, proxyCovenant.ParentID.ToString());
            proxyCovenant.ID = nso.Id;

            /*
             * [DataMember]
            public string CovenantType { get; set; }
            [DataMember]
            public string Reference { get; set; }
            [DataMember]
            public string FrequencyOfReview { get; set; }
            [DataMember]
            public string RemarksIssues { get; set; }
            [DataMember]
            public DateTime? DueDate { get; set; }
            [DataMember]
            public string CompliedWith { get; set; }
            [DataMember]
            public DateTime SubmissionDate { get; set; }
            [DataMember]
            public string Status { get; set; }
             */
            proxyCovenant.CovenantType = EnsureValueFromOptionSet(nso, "new_type");
            proxyCovenant.Reference = nso.new_Reference;
            proxyCovenant.FrequencyOfReview = EnsureValueFromOptionSet(nso, "new_frequencyofreview");
            proxyCovenant.RemarksIssues = nso.new_RemarksIssues;
            proxyCovenant.DueDate = nso.new_DueDate;
            proxyCovenant.CompliedWith = EnsureValueFromOptionSet(nso, "new_compliedwith");
            proxyCovenant.CompliedWithID = nso.new_CompliedWith;
            proxyCovenant.SubmissionDate = nso.new_SubmissionDate;
            proxyCovenant.Status = EnsureValueFromOptionSet(nso, "new_status");
            proxyCovenant.StatusID = nso.new_Status;
            return proxyCovenant;
        }