Esempio n. 1
0
        public IndividualLead CreateIndividualLead(IndividualLead lead)
        {
            var  entity = CastToCrmEntity(lead);
            Guid leadId = GlobalCode.Service.Create(entity);

            lead.Id = leadId.ToString();
            return(lead);
        }
Esempio n. 2
0
        public HttpResponseMessage CreateIndividualLeadWithCompleteProfile(IndividualLead Lead)
        {
            var    re      = Request;
            var    headers = re.Headers;
            string Source  = "";

            if (headers.Contains("source"))
            {
                Source = headers.GetValues("source").First();
            }
            var LeadManager = new LeadManager();

            if (LeadManager.GetLeadsByMobile(Lead.Mobile, Language).Count() > 1)
            {
                return(OkResponse <ReturnData>(new ReturnData()
                {
                    State = false,
                    Data = new { message = Language == UserLanguage.Arabic ? "هذا العميل لديه طلبـات سابقة" : "This client has prior requests", user = Lead }
                }));
            }



            using (var ContactManager = new ContactManager())
            {
                if (!ContactManager.IsProfileCompleted(Lead.ContactId))
                {
                    Contact contact = ContactManager.GetContact(Lead.ContactId);
                    contact.CityId        = Lead.CityId ?? contact.CityId;
                    contact.IdNumber      = Lead.IdNumber == null?  contact.IdNumber : Lead.IdNumber.ToString();
                    contact.JobTitle      = Lead.JobTitle ?? contact.JobTitle;
                    contact.RegionId      = Lead.RegionId ?? contact.RegionId;
                    contact.Email         = Lead.Email ?? contact.Email;
                    contact.NationalityId = Lead.NationalityId ?? contact.NationalityId;
                    contact.GenderId      = Lead.GenderId ?? contact.GenderId;

                    ContactManager.UpdateCrmEntityBeforeContract(contact);
                }
            }
            Lead.Source = Source == "1" ? Enums.RecordSource.Mobile : Enums.RecordSource.Web;
            var result = Manager.CreateIndividualLead(Lead);

            return(OkResponse <ReturnData>(new ReturnData()
            {
                State = true,
                Data = new { user = result }
            }));
        }
Esempio n. 3
0
        public Entity CastToCrmEntity(IndividualLead lead)
        {
            Entity entity = new Entity(CrmEntityName);

            entity["new_nationalityid"]  = new EntityReference(CrmEntityNamesMapping.Nationality, new Guid(lead.RequiredNationality));
            entity["new_profrequiredid"] = new EntityReference(CrmEntityNamesMapping.Profession, new Guid(lead.RequiredProfession));
            entity["new_medicallead"]    = (lead.IsMedicalLead ?? false);
            entity["firstname"]          = lead.Name;
            entity["mobilephone"]        = lead.Mobile;
            entity["jobtitle"]           = lead.JobTitle;
            entity["new_cityid"]         = new EntityReference(CrmEntityNamesMapping.City, new Guid(lead.CityId));
            entity["new_sector"]         = new OptionSetValue(Convert.ToInt32(SectorsTypeEnum.Individuals));
            entity["new_region"]         = !String.IsNullOrEmpty(lead.RegionId) ? new EntityReference(CrmEntityNamesMapping.Territory, new Guid(lead.RegionId)) : null;
            entity["telephone2"]         = lead.HomePhone;
            entity["new_idnumber"]       = lead.IdNumber.ToString();
            entity["new_districtid"]     = String.IsNullOrEmpty(lead.DistrictId) ? null : new EntityReference(CrmEntityNamesMapping.District, new Guid(lead.DistrictId));
            entity["description"]        = lead.Description;
            entity["new_recordsource"]   = lead.Source.HasValue  ?  new OptionSetValue((int)lead.Source) : new OptionSetValue(2);
            return(entity);
        }
Esempio n. 4
0
        public HttpResponseMessage GetLeadsByMobile(IndividualLead Lead)
        {
            var leadManager = new LeadManager();

            return(OkResponse <bool>(leadManager.GetLeadsByMobile(Lead.Mobile, Language).Count() > 1));
        }
Esempio n. 5
0
        public HttpResponseMessage CreateIndividualLead(IndividualLead Lead)
        {
            var result = Manager.CreateIndividualLead(Lead);

            return(OkResponse <IndividualLead>(result));
        }