Example #1
0
        public LeadDetailsModel Creation(LeadCreateModel leadModel)
        {
            // TODO: Resolve Usuario atual(Logado)
            var userId = 1;

            leadModel.CreatedById = userId;

            var lead = _mapper.Map <Lead>(leadModel);

            // TODO: Validator
            _leadValidator.Creation(lead);

            // TODO: Chama repository
            var leadRepository = _unitOfWork.GetRepository <ILeadRepository>();
            var leadCreated    = leadRepository.Create(lead);

            LeadDetailsModel leadDetailsModel = new LeadDetailsModel();

            // TODO: Commit
            if (!_unitOfWork.Commit())
            {
                leadDetailsModel.Erros = _mapper.Map <List <ErroModel> >(_notificationHandler.GetNotifications());
                return(leadDetailsModel);
            }

            // TODO: Devolver objeto sucesso ou falha
            leadDetailsModel = _mapper.Map <LeadDetailsModel>(lead);

            return(leadDetailsModel);
        }
Example #2
0
 private void GenerateLinksForLead(Guid id, LeadDetailsModel leadDetails)
 {
     leadDetails.Links = leadDetails.LeadStage == 2
         ? null
         : new List <Link>()
     {
         new Link(
             $"{this.Request.Scheme}://{this.Request.Host}{this.Request.PathBase}/leads/{ id }",
             "self",
             "GET"
             ),
         new Link(
             $"{this.Request.Scheme}://{this.Request.Host}{this.Request.PathBase}/leads/{ id }/notes/add",
             "add-note",
             "POST"
             ),
         new Link(
             $"{this.Request.Scheme}://{this.Request.Host}{this.Request.PathBase}/leads/{ id }/update",
             "update-client",
             "PATCH"
             ),
         new Link(
             $"{this.Request.Scheme}://{this.Request.Host}{this.Request.PathBase}/leads/{ id }/updatevalue",
             "update-value",
             "PATCH"
             ),
         new Link(
             $"{this.Request.Scheme}://{this.Request.Host}{this.Request.PathBase}/leads/{ id }/close",
             "close-lead",
             "PUT"
             )
     };
 }