Exemple #1
0
        public static Invoice ToDomain(InvoiceEntity invoice, OpportunityEntity opportunity)
        {
            var domain = ToDomain(invoice);

            domain.Opportunity = OpportunityConverter.ToDomainObject(opportunity);
            return(domain);
        }
 public void Remove(OpportunityEntity entity)
 {
     if (_internalRepository.Any(o => o.Id == entity.Id))
     {
         _internalRepository.Remove(_internalRepository.First(o => o.Id.Equals(entity.Id)));
     }
 }
Exemple #3
0
 public static Opportunity ToDomainObject(OpportunityEntity o)
 {
     return(new Opportunity
     {
         AccountId = o.AccountId,
         Created = o.Created,
         Id = o.Id,
         Name = o.Name
     });
 }
Exemple #4
0
        protected static void createOpportunity(string name, AccountEntity account)
        {
            var newOpp = new OpportunityEntity()
            {
                Name      = name,
                AccountId = account.Id
            };

            context.Create <OpportunityEntity>(newOpp);
            context.SaveChanges();
        }
Exemple #5
0
        protected static void createInvoice(string name, OpportunityEntity opportunity)
        {
            var newInv = new InvoiceEntity()
            {
                Name          = name,
                AccountId     = opportunity.AccountId,
                OpportunityId = opportunity.Id
            };

            context.Create <InvoiceEntity>(newInv);
            context.SaveChanges();
        }
        public Guid Create(Opportunity opportunity)
        {
            var entity = new OpportunityEntity
            {
                Name      = opportunity.Name,
                AccountId = opportunity.AccountId
            };

            Context.Create(entity);
            Context.SaveChanges();

            return(entity.Id);
        }
        public async Task <int> AddOpportunities(OpportunityEntity opportunity)
        {
            string sqlInsertQuery = @"
                INSERT INTO [dbo].[Opportunity]([LeadId], [Description]) 
                    values(@leadId, @description)
            ";

            DynamicParameters insertParameters = new DynamicParameters();

            insertParameters.Add("@leadId", opportunity.LeadId, DbType.Int32);
            insertParameters.Add("@description", opportunity.Description, DbType.AnsiString);

            return(await ExecutarAsync(sqlInsertQuery, insertParameters));
        }
        private List <OpportunityEntity> GetMockOpportunities()
        {
            List <OpportunityEntity> opportunityEntities = new List <OpportunityEntity>();
            OpportunityEntity        opportunityEntity   = new OpportunityEntity();

            opportunityEntity.AccountSalesforceReference     = "DS110162896";
            opportunityEntity.BookerSalesforceReference      = "CON-000528067";
            opportunityEntity.EndCustomerSalesforceReference = "CON-000528067";

            List <OpportunityLineItemEntity> opportunityLineItemEntities = new List <OpportunityLineItemEntity>();
            OpportunityLineItemEntity        opportunityLineItemEntity   = new OpportunityLineItemEntity();

            opportunityLineItemEntity.AutoRenewal = true;
            opportunityLineItemEntities.Add(opportunityLineItemEntity);

            opportunityEntity.OpportunityLineItemEntities = opportunityLineItemEntities;
            opportunityEntities.Add(opportunityEntity);

            return(opportunityEntities);
        }
Exemple #9
0
        public async Task <RegisterLeadOutput> RegisterLead(RegisterLeadInput request)
        {
            var status = await _leadRepository.AddStatus(request.StatusDescription);

            //var allStatusLead = await _leadRepository.ListAllStatusLead();
            //if (!allStatusLead.Any())
            //throw new DefaultException((int)HttpStatusCode.InternalServerError, "Nenhum status lead encontrado.");

            LeadEntity input = new LeadEntity()
            {
                CustomerName  = request.CustomerName,
                CustomerEmail = request.CustomerEmail,
                CustomerPhone = request.CustomerPhone,
                StatusId      = status.Id
            };

            var lead = await _leadRepository.AddLead(input);

            foreach (var item in request.Opportunities)
            {
                var opportunity = new OpportunityEntity()
                {
                    LeadId      = lead.Id,
                    Description = item
                };
                await _leadRepository.AddOpportunities(opportunity);
            }

            var opportunitiesOfLead = await _leadRepository.ListOpportunitiesByLeadId(lead.Id);

            var leadDto = lead.CreateDto();

            leadDto.Opportunities = new List <OpportunityDto>();
            opportunitiesOfLead.ToList().ForEach(item => leadDto.Opportunities.Add(item.CreateDto()));

            return(new RegisterLeadOutput()
            {
                Method = "RegisterLead",
                Result = lead != default ? "SUCCESS" : "ERROR",
                Payload = leadDto
            });
Exemple #10
0
 public void Save(OpportunityEntity entity)
 {
     _repository.Save(entity);
 }
Exemple #11
0
 public void Remove(OpportunityEntity entity)
 {
     Remove(entity);
 }
 public IActionResult Put(string id, [FromBody] OpportunityEntity opportunity)
 {
     _opportunityService.Save(opportunity);
     return(Ok(new { message = $"Let's just pretend like I updated that '{id}' thing to '{opportunity.Id}' for you..." }));
 }
 public IActionResult Post([FromBody] OpportunityEntity opportunity)
 {
     _opportunityService.Save(opportunity);
     return(Ok(new { message = $"Let's just pretend like I created that '{opportunity.Id}' thing for you..." }));
 }
 public void Save(OpportunityEntity entity)
 {
     Remove(entity);
     _internalRepository.Add(entity);
 }
Exemple #15
0
 public static OpportunityDto CreateDto(this OpportunityEntity input)
 {
     if (input == default)
     {
         return(default);