Exemple #1
0
        private bool GetResponseSearch(string response, object value)
        {
            LeadRoot lead = (LeadRoot)value;

            try
            {
                var responseObject = JsonConvert.DeserializeObject(response, typeof(RootObject));
                if (!((RootObject)responseObject).response.result.Potentials.row.FL.content.Equals(string.Empty))
                {
                    lead.Lead.Id = ((RootObject)responseObject).response.result.Potentials.row.FL.content;
                    return(true);
                }
            }
            catch
            {
                try
                {
                    var responseObject = JsonConvert.DeserializeObject(response, typeof(Models.Json.Test.RootObject));
                    if (!((Models.Json.Test.RootObject)responseObject).response.result.Potentials.row[0].FL.content.Equals(string.Empty))
                    {
                        lead.Lead.Id = ((Models.Json.Test.RootObject)responseObject).response.result.Potentials.row[0].FL.content;
                        return(true);
                    }
                }
                catch { return(false); }
            }
            return(false);
        }
Exemple #2
0
 private bool ExecuteLead(LeadRoot value)
 {
     if (string.IsNullOrEmpty(value.GetId()))
     {
         OnGetIdLead(value);
     }
     return(OnExecuteLead(value, value.MappingFields));
 }
Exemple #3
0
        public string GetIdPotential(Authentication value, string id)
        {
            LeadRoot lead = new LeadRoot {
                Authentication = value, Lead = new Lead()
            };

            if (SendRequestGetRecord(lead, id, LoadResponsePotential))
            {
                return(lead.GetId());
            }
            return(string.Empty);
        }
Exemple #4
0
        public bool Execute(LeadRoot lead, List <MappingFields> mapping)
        {
            mapping.Add(new MappingFields {
                Entity = "Potential", Field = "Closing Date", Value = DateTime.Now.AddMonths(1).ToString("yyy-MM-dd hh:mm:ss")
            });

            if (string.IsNullOrEmpty(lead.GetId()))
            {
                mapping.Add(new MappingFields {
                    Entity = "Potential", Field = "Stage", Value = "Qualificação"
                });
            }

            return(SendRequestSave(lead, mapping.Where(w => FilterEntity(w.Entity)).ToList(), GetResponse));
        }
Exemple #5
0
        private bool LoadResponsePotential(string response, object value)
        {
            LeadRoot lead = (LeadRoot)value;

            try
            {
                var responseObject = JsonConvert.DeserializeObject(response, typeof(Models.Zoho.GetRecord.RootObject));
                if (((Models.Zoho.GetRecord.RootObject)responseObject).response.result.Events.row.FL.Exists(e => e.val.Equals("RELATEDTOID")))
                {
                    lead.Lead.Id = ((Models.Zoho.GetRecord.RootObject)responseObject).response.result.Events.row.FL
                                   .Where(e => e.val.Equals("RELATEDTOID")).First().content;
                    return(true);
                }
            }
            catch
            { }
            return(false);
        }
Exemple #6
0
        public bool Execute(ScheduleRoot schedule, List <MappingFields> mapping)
        {
            Predicate <MappingFields> filterName = m => m.Field.Equals(FIELD_NAME);
            var potentialName = mapping.Where(w => filterName(w)).First().Value;

            LeadRoot lead = new LeadRoot {
                Lead = schedule.Lead, Authentication = schedule.Authentication, MappingFields = mapping
            };

            SendRequestSearch(lead, GetEntityName(), FIELD_SELECT, FIELD_SEARCH, potentialName, GetResponseSearch);

            if (Execute(lead, mapping.Where(w => FilterEntity(w.Entity)).ToList()))
            {
                if (!schedule.MappingFields.Exists(e => ZohoEvent.Filter(e.Entity) && e.Field.Equals("SEMODULE")))
                {
                    lead.MappingFields.Where(w => ZohoEvent.Filter(w.Entity)).ToList().ForEach(f => { schedule.MappingFields.Add(f); });
                }
                return(true);
            }
            return(false);
        }
Exemple #7
0
 public bool LeadUpdate(LeadRoot value) => Execute(value, (c, v) => c.LeadUpdate((LeadRoot)v));
Exemple #8
0
 public bool LeadRegister(LeadRoot value) => Execute(value, (c, v) => c.LeadRegister((LeadRoot)v));
Exemple #9
0
 public bool GetId(LeadRoot value)
 {
     return(SendRequestSearch(value, GetEntityName(), FIELD_SELECT, FIELD_SEARCH, value.GetId(), GetResponseSearch));
 }
Exemple #10
0
 protected override bool OnGetIdLead(LeadRoot value) => PotentialController.GetId(value);
Exemple #11
0
 protected override bool OnExecuteLead(LeadRoot value, List <MappingFields> list) => PotentialController.Execute(value, list);
Exemple #12
0
 protected abstract bool OnGetIdLead(LeadRoot value);
Exemple #13
0
 protected abstract bool OnExecuteLead(LeadRoot value, List <MappingFields> list);
Exemple #14
0
 public bool LeadUpdate(LeadRoot value) => ExecuteLead(value);
Exemple #15
0
 public bool LeadRegister(LeadRoot value) => ExecuteLead(value);