public Budget Create(CreateBudgetCommand command)
        {
            var service = new Budget(command.Proposal, command.Price, command.ProposalDate, command.Status, command.SessionPrice, command.IdCoachingProcess);
            service.Validate();
            _repository.Create(service);

            if (Commit())
                return service;

            return null;
        }
Ejemplo n.º 2
0
        public Task<HttpResponseMessage> Post([FromBody]dynamic body)
        {
            var commandBudget = new CreateBudgetCommand(
                proposal: (string)body.proposal,
                price: (float)body.price,
                status: EBudgetStatus.Enviado,
                proposalDate: DateTime.Now,
                sessionPrice: (float)body.sessionPrice,
                idCoachingProcess: (Guid)body.idCoachingProcess
               );

            var budget = _serviceBudget.Create(commandBudget);
            var coachingProcess = _serviceCoachingProcess.GetOneIncludeDetails(budget.IdCoachingProcess);
            string msg = budget.Proposal + "\n Preço da sessão: " + budget.Price + "\n Total: " + budget.Price;
            foreach (var coachee in coachingProcess.Coachee)
                _serviceUser.SendEmail(coachee.IdUser, "Orçamento processo de coaching - CoachingPlan", msg);

            return CreateResponse(HttpStatusCode.Created, budget);
        }