//// your properties
    public LeadDto GetOtherObject()
    {
        LeadDto object = new LeadDto();

        ////Map properties from this to object
        return(object);
    }
Ejemplo n.º 2
0
    public static LeadDto GetOtherObject(Lead leadObject)
    {
        LeadDto object = new LeadDto();

        ////Map properties from leadObject to object
        return(object);
    }
Ejemplo n.º 3
0
        internal IFacadeUpdateResult <LeadData> SaveLead(LeadDto dto)
        {
            ArgumentValidator.IsNotNull("dto", dto);

            FacadeUpdateResult <LeadData> result = new FacadeUpdateResult <LeadData>();
            ILeadService service  = UnitOfWork.GetService <ILeadService>();
            Lead         instance = RetrieveOrNew <LeadData, Lead, ILeadService>(result.ValidationResult, dto.Id);

            if (result.IsSuccessful)
            {
                instance.FullName     = dto.FullName;
                instance.FamilyName   = dto.FamilyName;
                instance.Gender       = dto.Gender;
                instance.AddressLine1 = dto.AddressLine1;
                instance.AddressLine2 = dto.AddressLine2;
                instance.Country      = dto.Country;
                instance.CountryState = dto.CountryState;
                instance.City         = dto.City;
                instance.ZipCode      = dto.ZipCode;
                instance.Phone        = dto.Phone;
                instance.Fax          = dto.Fax;
                instance.Email        = dto.Email;

                var saveQuery = service.Save(instance);

                result.AttachResult(instance.RetrieveData <LeadData>());
                result.Merge(saveQuery);
            }

            return(result);
        }
Ejemplo n.º 4
0
        public LeadResponse CreateLead(LeadDto leadDto, bool sendMail)
        {
            var response = new LeadResponse();

            try
            {
                UserService _userService = new UserService();

                // _userService.GetUserInformation
                if (ValidateLeadEmail(leadDto.Email))
                {
                    var leadRepository = new LeadRepository();
                    var newLead        = new Lead()
                    {
                        Aliases             = leadDto.Aliases,
                        CountryCode         = leadDto.CountryCode,
                        DateCreated         = leadDto.DateCreated,
                        DateUpdated         = leadDto.DateUpdated,
                        Email               = leadDto.Email,
                        FirstName           = leadDto.FirstName,
                        LastName            = leadDto.LastName,
                        Keywords            = leadDto.Keywords,
                        PhoneNumber         = leadDto.PhoneNumber,
                        MarketSegments      = leadDto.MarketSegments,
                        OtherMarketSegments = leadDto.OtherMarketSegments,
                        IntakeEmailSentDate = DateTime.Now,
                        IntakeToken         = leadDto.IntakeToken,
                        IntakeUrl           = leadDto.IntakeUrl,
                        IsActive            = true,
                        IsIntakeAnswered    = false
                    };
                    leadRepository.Add(newLead);
                    leadRepository.SaveChanges();
                    leadDto.idLead          = newLead.idLead;
                    response.Acknowledgment = true;
                    response.Message        = "Success";

                    if (sendMail)
                    {
                        SendLeadConfirmationEmail(leadDto.Email, leadDto.FirstName, leadDto.IntakeUrl);
                    }
                    response.Lead = leadDto;
                }
                else
                {
                    //response.Acknowledgment = false;
                    //response.Message = "Error Adding a Lead: Email already exist";
                    //response.Lead = null;
                    throw new System.ArgumentException("The email is already registered as a user. Please choose another one.");
                }
            }
            catch (Exception ex)
            {
                response.Acknowledgment = false;
                response.Message        = ex.Message;
                response.Lead           = null;
            }
            return(response);
        }
Ejemplo n.º 5
0
 public static void UpdateCallStatusAsync(LeadDto model, Lead entity, string userId)
 {
     entity.Id         = model.Id;
     entity.CallStatus = model.CallStatus;
     entity.CreatedBy  = userId ?? "0";
     entity.CreatedOn  = Utility.GetDateTime();
     entity.UpdatedBy  = userId ?? "0";
     entity.UpdatedOn  = Utility.GetDateTime();
 }
Ejemplo n.º 6
0
        public void SaveLead(LeadDto leadDto)
        {
            var lead = _mapper.Map <Lead>(leadDto);

            lead.StatusId = _statusLeadService.GetIdByDescription("Cliente em Potencial");
            lead.Date     = DateTime.Now;
            _context.Leads.Add(lead);
            _context.SaveChanges();
        }
Ejemplo n.º 7
0
        public GetLeadByIdResultDto Execute(GetLeadByIdDto dto)
        {
            GetLeadByIdResultDto result = new GetLeadByIdResultDto {
                Status = true
            };
            LeadDto lst = unit.Lead.GetLeadById(dto);

            result.Object = lst;
            return(result);
        }
Ejemplo n.º 8
0
        public IActionResult Add([FromBody] LeadDto dto)
        {
            //check number
            dto.MobileNo = PhoneNoModule.NormalizePhoneNoFormat(dto.MobileNo);
            if (!PhoneNoModule.isPhoneNumberValid(dto.MobileNo))
            {
                return(BadRequest("Mobile number not valid. Needs to 12 Characters"));
            }

            if (!_leadTypeRepository.All.Any(s => s.Id == dto.LeadTypeId))
            {
                return(BadRequest($"Lead type {dto.LeadTypeId} not valid"));
            }

            if (!string.IsNullOrWhiteSpace(dto.ProductBracket) && !_mobileProductRepository.GetProductsByBracket(dto.ProductBracket).Any())
            {
                return(BadRequest($"No product found for {dto.ProductBracket}"));
            }

            //check if lead is active
            var currentlead = _leadRepo.FindOpenLeadByMobileNo(dto.MobileNo);

            if (currentlead.IsSome)
            {
                if (currentlead.Val.IsClosed == false)
                {
                    currentlead.Val.Close();
                    _leadRepo.Update(currentlead.Val);
                }
            }
            //LeadTypeModule
            var leadType = new LeadType(dto.LeadTypeId);
            var lead     = new Lead(leadType, dto.MobileNo, dto.FirstName.StrToOpt())
            {
                ProductBracket  = dto.ProductBracket.StrToOpt(),
                IdNumber        = dto.IdNumber.StrToOpt(),
                Surname         = dto.Surname.StrToOpt(),
                ExternalRefNo   = dto.ExternalRefNo.StrToOpt(),
                BankName        = dto.BankName.StrToOpt(),
                BankAccountType = dto.BankAccountType.StrToOpt(),
                BankAccountNo   = dto.BankAccountNo.StrToOpt(),
                EmployerName    = dto.EmployerName.StrToOpt(),
                EmployerNumber  = dto.EmployerNumber.StrToOpt(),
                EmployerAddress = string.IsNullOrEmpty(dto.EmployerAddressStreet) ? None <Address>() :  Some(new Address(dto.EmployerAddressStreet, dto.EmployerAddressSuburb, dto.EmployerAddressCity, dto.EmployerAddressPostalCode)),
                HomeAddress     = string.IsNullOrEmpty(dto.HomeAddressStreet) ? None <Address>() : Some(new Address(dto.HomeAddressStreet, dto.HomeAddressSuburb, dto.HomeAddressCity, dto.HomeAddressPostalCode))
            };

            _leadRepo.Add(lead);

            return(Ok("Lead Created"));
        }
Ejemplo n.º 9
0
        public JsonResult AddLead(string token, string firstName, string lastName, string email, string countryCode, string phoneNumber, string aliases, string keywords, string productName, string productURL, string marketSegments, string otherMarketSegments, string competitors, string notes, string idLead, string ProductType)
        {
            try
            {
                //TODO Prepare Image for Database
                token = Guid.NewGuid().ToString();

                var leadDto = new LeadDto()
                {
                    //The intake token to identify the "lead" in the database
                    IntakeToken = token,

                    //from the First Step
                    FirstName   = firstName,
                    LastName    = lastName,
                    Email       = email,
                    CountryCode = countryCode,
                    PhoneNumber = phoneNumber,
                    DateUpdated = DateTime.Now,
                    DateCreated = DateTime.Now,
                    IntakeUrl   = "",

                    //From the 2nd step
                    Aliases             = aliases,
                    Keywords            = keywords,
                    ProductName         = productName,
                    ProductURL          = productURL,
                    MarketSegments      = marketSegments,
                    OtherMarketSegments = otherMarketSegments,
                    Competitors         = competitors,
                    Notes    = notes,
                    IsActive = true,
                    //idLead = int.Parse(idLead)
                };
                LeadResponse response = _leadService.CreateLead(leadDto, false);

                if (response.Acknowledgment == false && ProductType == "Trial")
                {
                    throw new System.ArgumentException("The email is already registered as a user. Please choose another one.");
                }

                var url = ConfigurationManager.AppSettings[ProductType] + "?first_name=" + firstName + "&last_name=" + lastName + "&email=" + email + "&reference=" + token + "&phone=" + countryCode + phoneNumber;
                return(Json(new { success = true, toUrl = url }));
            }catch (Exception e)
            {
                return(Json(new { success = false, message = e.Message }));
            }
            ///return Redirect(url);
        }
Ejemplo n.º 10
0
        public async ValueTask <DataWrapper <LeadDto> > AddOrUpdateLead(LeadDto leadDto)
        {
            var leadDictionary = new Dictionary <long, LeadDto>();
            var result         = new DataWrapper <LeadDto>();

            try
            {
                var tmp = await _connection.QueryAsync <LeadDto, RoleDto, CityDto, AccountDto, LeadDto>(
                    StoredProcedures.LeadAddOrUpdate,
                    (lead, role, city, account) =>
                {
                    LeadDto leadEntry;
                    if (!leadDictionary.TryGetValue(lead.Id.Value, out leadEntry))
                    {
                        leadEntry          = lead;
                        leadEntry.Accounts = new List <AccountDto>();
                        leadDictionary.Add(leadEntry.Id.Value, leadEntry);
                        leadEntry.Role = role;
                        leadEntry.City = city;
                    }
                    leadEntry.Accounts.Add(account);
                    return(leadEntry);
                },
                    new
                {
                    leadDto.Id,
                    leadDto.FirstName,
                    leadDto.LastName,
                    leadDto.Patronymic,
                    leadDto.Login,
                    leadDto.Password,
                    leadDto.Phone,
                    leadDto.Email,
                    CityId = leadDto.City.Id,
                    leadDto.Address,
                    leadDto.BirthDate
                }, splitOn : "Id",
                    commandType : CommandType.StoredProcedure);

                result.Data = tmp.FirstOrDefault();
                result.IsOk = true;
            }
            catch (Exception e)
            {
                result.ExceptionMessage = e.Message;
            }
            return(result);
        }
Ejemplo n.º 11
0
        public LeadDto CreateLead(LeadDto objLeadDto)
        {
            using (var transaction = _context.Database.BeginTransaction())
            {
                try
                {
                    Leads objLeads = _mapper.Map <Leads>(objLeadDto);
                    objLeads.CreatedDateTime = DateTime.Now;
                    objLeads.CreatedBy       = 1;
                    _context.Leads.Add(objLeads);
                    _context.SaveChanges();

                    foreach (var product in objLeadDto.ProductList)
                    {
                        ProductListDto objProductListDto = product;
                        ProductList    objProductList    = _mapper.Map <ProductList>(objProductListDto);
                        objProductList.ReferenceId     = objLeads.LeadId;
                        objProductList.Source          = 1;
                        objProductList.ProductId       = product.ProductId;
                        objProductList.CreatedBy       = 1;
                        objProductList.CreatedDateTime = DateTime.Now;
                        _context.ProductList.Add(objProductList);
                    }

                    foreach (var activity in objLeadDto.Activities)
                    {
                        ActivitiesDto objActivitiesDto = activity;
                        Activities    objActivities    = _mapper.Map <Activities>(objActivitiesDto);
                        objActivities.ReferenceId     = objLeads.LeadId;
                        objActivities.Source          = 1;
                        objActivities.CreatedBy       = 1;
                        objActivities.CreatedDateTime = DateTime.Now;
                        _context.Activities.Add(objActivities);
                    }

                    _context.SaveChanges();
                    transaction.Commit();
                    return(_mapper.Map <LeadDto>(_context.Leads.
                                                 SingleOrDefault(x => x.LeadId == objLeads.LeadId)));
                }
                catch (Exception)
                {
                    transaction.Rollback();
                    throw;
                }
            }
        }
Ejemplo n.º 12
0
 public static void updateLead(LeadDto model, Lead entity, String userId)
 {
     entity.Id          = model.Id;
     entity.FirstName   = model.FirstName;
     entity.LastName    = model.LastName;
     entity.Email       = model.Email;
     entity.Website     = model.Website;
     entity.Mobile      = model.Mobile;
     entity.Phone       = model.Phone;
     entity.UpdatedBy   = userId ?? "0";
     entity.CompanyName = model.CompanyName;
     entity.UpdatedOn   = Utility.GetDateTime();
     entity.UserId      = model.UserId;
     entity.CallStatus  = model.CallStatus;
     entity.CreatedBy   = userId ?? "0";
     entity.CreatedOn   = Utility.GetDateTime();
 }
Ejemplo n.º 13
0
        public JsonResult AddFirstStep(string firstName, string lastName, string email, string countryCode, string phoneNumber)
        {
            var token   = Guid.NewGuid().ToString();
            var leadDto = new LeadDto()
            {
                FirstName   = firstName,
                LastName    = lastName,
                Email       = email,
                CountryCode = countryCode,
                PhoneNumber = phoneNumber,
                DateUpdated = DateTime.Now,
                DateCreated = DateTime.Now,
                IntakeUrl   = Request.Url.GetLeftPart(UriPartial.Authority) + Url.Content("~") + "Intake/MoreInformation?token=" + token,
                IntakeToken = token
            };

            return(Json(_leadService.CreateLead(leadDto, true), JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 14
0
        public IActionResult PostLead([FromBody] LeadDto leadDto)
        {
            var response = new ResponseDto {
                Metodo = nameof(PostLead)
            };

            try
            {
                _leadService.SaveLead(leadDto);
                response.Resutado = ResultadoResponse.Sucesso;
                return(Created("", response));
            }
            catch (UnprocessableEntityException e)
            {
                response.Resutado = ResultadoResponse.Erro;
                response.Payload  = new { message = e.Message };
                return(UnprocessableEntity(response));
            }
        }
Ejemplo n.º 15
0
        public JsonResult AddSecondStep(string token, string firstName, string lastName, string email, string countryCode, string phoneNumber, string aliases, string keywords, string productName, string productURL, string marketSegments, string otherMarketSegments, string competitors, string notes, string idLead)
        {
            //TODO Prepare Image for Database

            var leadDto = new LeadDto()
            {
                //The intake token to identify the "lead" in the database
                IntakeToken = token,

                //from the First Step
                FirstName   = firstName,
                LastName    = lastName,
                Email       = email,
                CountryCode = countryCode,
                PhoneNumber = phoneNumber,
                DateUpdated = DateTime.Now,
                DateCreated = DateTime.Now,
                IntakeUrl   = "",

                //From the 2nd step
                Aliases             = aliases,
                Keywords            = keywords,
                ProductName         = productName,
                ProductURL          = productURL,
                MarketSegments      = marketSegments,
                OtherMarketSegments = otherMarketSegments,
                Competitors         = competitors,
                Notes    = notes,
                IsActive = true,
                idLead   = int.Parse(idLead)
            };
            var urlToValidateUser =
                ConfigurationManager.AppSettings["SmartSocialWeb"];


            return(Json(_leadService.UpdateLead(leadDto, urlToValidateUser), JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 16
0
        public async ValueTask <DataWrapper <List <LeadDto> > > SearchLeads(LeadSearchParameters searchParameters)
        {
            var     leadDictionary = new Dictionary <long, LeadDto>();
            var     results        = new DataWrapper <List <LeadDto> >();
            LeadDto leadEntry      = new LeadDto();

            try
            {
                var tmp = await _connection.QueryAsync <LeadDto, RoleDto, CityDto, AccountDto, LeadDto>(
                    StoredProcedures.LeadSearch,
                    (lead, role, city, account) =>
                {
                    LeadDto leadEntry;
                    if (!leadDictionary.TryGetValue(lead.Id.Value, out leadEntry))
                    {
                        leadEntry          = lead;
                        leadEntry.Accounts = new List <AccountDto>();
                        leadDictionary.Add(leadEntry.Id.Value, leadEntry);
                        leadEntry.Role = role;
                        leadEntry.City = city;
                    }
                    leadEntry.Accounts.Add(account);
                    return(leadEntry);
                },
                    searchParameters, splitOn : "Id",
                    commandType : CommandType.StoredProcedure);

                results.Data = tmp.ToList();
                results.IsOk = true;
                results.Data = new List <LeadDto> (leadDictionary.Values);
            }
            catch (Exception e)
            {
                results.ExceptionMessage = e.Message;
            }
            return(results);
        }
Ejemplo n.º 17
0
 public LeadDtoBuilder()
 {
     _leadDto = new LeadDto();
 }
Ejemplo n.º 18
0
        public BaseResponse UpdateLead(LeadDto leadDto, string urlToValidateUser)
        {
            var response = new BaseResponse();

            try
            {
                var leadRepository = new LeadRepository();
                var currentLead    = leadRepository.Query().FirstOrDefault(x => x.idLead == leadDto.idLead);

                if (currentLead != null)
                {
                    currentLead.FirstName   = (leadDto.FirstName != null && !leadDto.FirstName.Equals("")) ? leadDto.FirstName : currentLead.FirstName;
                    currentLead.LastName    = (leadDto.LastName != null && !leadDto.LastName.Equals("")) ? leadDto.LastName : currentLead.LastName;
                    currentLead.CountryCode = (leadDto.CountryCode != null && !leadDto.CountryCode.Equals("")) ? leadDto.CountryCode : currentLead.CountryCode;
                    currentLead.PhoneNumber = (leadDto.PhoneNumber != null && !leadDto.PhoneNumber.Equals("")) ? leadDto.PhoneNumber : currentLead.PhoneNumber;
                    currentLead.Email       = (leadDto.Email != null && !leadDto.Email.Equals("")) ? leadDto.Email : currentLead.Email;

                    currentLead.ProductName = (leadDto.ProductName != null && !leadDto.ProductName.Equals("")) ? leadDto.ProductName : currentLead.ProductName;
                    currentLead.ProductURL  = (leadDto.ProductURL != null && !leadDto.ProductURL.Equals("")) ? leadDto.ProductURL : currentLead.ProductURL;
                    currentLead.Aliases     = (leadDto.Aliases != null && !leadDto.Aliases.Equals("")) ? leadDto.Aliases : currentLead.Aliases;
                    currentLead.Keywords    = (leadDto.Keywords != null && !leadDto.Keywords.Equals("")) ? leadDto.Keywords : currentLead.Keywords;

                    currentLead.Competitors         = (leadDto.Competitors != null && !leadDto.Competitors.Equals("")) ? leadDto.Competitors : currentLead.Competitors;
                    currentLead.Notes               = (leadDto.Notes != null && !leadDto.Notes.Equals("")) ? leadDto.Notes : currentLead.Notes;
                    currentLead.MarketSegments      = (leadDto.MarketSegments != null && !leadDto.MarketSegments.Equals("")) ? leadDto.MarketSegments : currentLead.MarketSegments;
                    currentLead.OtherMarketSegments = (leadDto.OtherMarketSegments != null && !leadDto.OtherMarketSegments.Equals("")) ? leadDto.OtherMarketSegments : currentLead.OtherMarketSegments;
                    currentLead.DateUpdated         = DateTime.Now;

                    currentLead.IsIntakeAnswered = true;
                    currentLead.IsActive         = leadDto.IsActive;
                }
                leadRepository.SaveChanges();

                // Create Chargify Suscription
                SubscriptionService chargifyService = new SubscriptionService();
                ISubscription       subscription    = null;

                if (currentLead.IntakeUrl == "")
                {
                    subscription = chargifyService.GetSubscription(int.Parse(currentLead.IntakeToken));
                }

                int serviceSuscriptionId = 0;
                if (subscription == null)
                {
                    subscription = chargifyService.SubscribeChargifyTrial(currentLead);

                    // Create System Suscription
                    if (subscription != null)
                    {
                        // Create Trial Suscription
                        serviceSuscriptionId = chargifyService.AddTrialServiceSubscription(subscription.SubscriptionID.ToString(), subscription.Customer.ChargifyID.ToString(), currentLead.idLead);
                    }
                    else
                    {
                        response.Acknowledgment = false;
                        response.Message        = "Invalid Charify Suscription";
                        return(response);
                    }
                }

                //Create new System User
                UserService _userService = new UserService();
                _userService.TrialCreateUser(currentLead.Email, 1, urlToValidateUser, subscription.SubscriptionID, subscription.Customer.ChargifyID, serviceSuscriptionId);

                // Send Lead Confirmation
                string token = WebSecurity.GeneratePasswordResetToken(currentLead.Email);
                SendTrialIntakeConfirmationEmail(currentLead.Email, currentLead.FirstName, urlToValidateUser + token);

                response.Acknowledgment = true;
                response.Message        = "Success";
            }
            catch (Exception ex)
            {
                response.Acknowledgment = false;
                response.Message        = "Error Updating a Lead: " + ex.Message;
            }
            return(response);
        }
Ejemplo n.º 19
0
 public IFacadeUpdateResult <LeadData> SaveLead(LeadDto dto)
 {
     return(LeadSystem.SaveLead(dto));
 }
Ejemplo n.º 20
0
        public LeadDto UpdateLead(LeadDto objLeadDto)
        {
            using (var transaction = _context.Database.BeginTransaction())
            {
                try
                {
                    Leads objLeads     = _mapper.Map <Leads>(objLeadDto);
                    Leads objLeadsData = _context.Leads.Find(objLeadDto.LeadId);
                    objLeads.ModifiedDateTime = DateTime.Now;
                    objLeads.ModifiedBy       = 1;
                    _context.Entry(objLeadsData).CurrentValues.SetValues(objLeads);

                    #region productlist update

                    foreach (var product in objLeadDto.ProductList)
                    {
                        if (product.ProductListId == 0)
                        {
                            ProductListDto objProductListDto = product;
                            ProductList    objProductList    = _mapper.Map <ProductList>(objProductListDto);
                            objProductList.ReferenceId     = objLeadDto.LeadId;
                            objProductList.Source          = 1;
                            objProductList.ProductId       = product.ProductId;
                            objProductList.CreatedBy       = 1;
                            objProductList.CreatedDateTime = DateTime.Now;
                            _context.ProductList.Add(objProductList);
                        }
                        else
                        {
                            ProductList    objProductListdata = _context.ProductList.Find(product.ProductListId);
                            ProductListDto objProductListDto  = product;
                            ProductList    objProductList     = _mapper.Map <ProductList>(objProductListDto);
                            objProductList.ModifiedBy       = 1;
                            objProductList.ModifiedDateTime = DateTime.Now;
                            _context.Entry(objProductListdata).CurrentValues.SetValues(objProductList);
                        }
                    }
                    #endregion

                    #region activities update

                    foreach (var activities in objLeadDto.Activities)
                    {
                        if (activities.ActivityId == 0)
                        {
                            ActivitiesDto objActivitiesDto = activities;
                            Activities    objActivities    = _mapper.Map <Activities>(objActivitiesDto);
                            objActivities.ReferenceId     = objLeadDto.LeadId;
                            objActivities.Source          = 1;
                            objActivities.CreatedBy       = 1;
                            objActivities.CreatedDateTime = DateTime.Now;
                            _context.Activities.Add(objActivities);
                        }
                        else
                        {
                            Activities    objActivitiesdata = _context.Activities.Find(activities.ActivityId);
                            ActivitiesDto objActivitiesDto  = activities;
                            Activities    objActivities     = _mapper.Map <Activities>(objActivitiesDto);
                            objActivities.ModifiedBy       = 1;
                            objActivities.ModifiedDateTime = DateTime.Now;
                            _context.Entry(objActivitiesdata).CurrentValues.SetValues(objActivities);
                        }
                    }
                    #endregion

                    _context.SaveChanges();
                    transaction.Commit();
                    return(_mapper.Map <LeadDto>(_context.Leads.
                                                 SingleOrDefault(x => x.LeadId == objLeadDto.LeadId)));
                }
                catch (Exception)
                {
                    transaction.Rollback();
                    throw;
                }
            }
        }
Ejemplo n.º 21
0
 public LeadDto SaveLead([FromBody] LeadDto model)
 {
     return(_leadService.CreateLead(model));
 }
Ejemplo n.º 22
0
 public LeadDto Update([FromBody] LeadDto model)
 {
     return(_leadService.UpdateLead(model));
 }