Example #1
0
        public static Agenda ToDomainModel(AgendaCommand agendaCommand)
        {
            var agenda = new Agenda(
                agendaCommand.DataInicioDoAgendamento,
                agendaCommand.ClienteId,
                agendaCommand.FuncionarioId,
                agendaCommand.TipoDeServicoId,
                agendaCommand.EstabelecimentoId,
                agendaCommand.IdAgenda);

            return(agenda);
        }
Example #2
0
        public Task <HttpResponseMessage> Post([FromBody] dynamic body)
        {
            var agendaCommand = new AgendaCommand(
                dataInicioDoAgendamento: (DateTime)body.startsAt,
                idCliente: (Guid)body.clienteId,
                idFuncionario: (Guid)body.funcionarioId,
                idTipoDeServico: (Guid)body.tipoDeServicoId,
                idEstabelecimento: (Guid)body.estabelecimentoId
                );

            var agenda = _agendaApp.Cadastrar(agendaCommand);

            return(CreateResponse(HttpStatusCode.Created, agenda));
        }
Example #3
0
        public AgendaCommand Cadastrar(AgendaCommand agendaCommand)
        {
            if (agendaCommand.TipoDeServicoId == null)
            {
                return(null);
            }

            var tipoDeServico = _tipoDeServicoService.ObterPorId(agendaCommand.TipoDeServicoId.Value);
            var agenda        = AgendaAdapter.ToDomainModel(agendaCommand);

            agenda.CalcularDataFimAgendamentoPeloTipoDeServico(tipoDeServico.TempoGastoEmMinutos);

            var agendaRetorno = _agendaService.Adicionar(agenda);

            if (Commit())
            {
                return(AgendaAdapter.ToModelDomain(_agendaService.ObterPorId(agendaRetorno.IdAgenda)));
            }

            return(null);
        }
Example #4
0
        public static AgendaCommand ToModelDomain(Agenda agenda)
        {
            if (agenda == null)
            {
                return(null);
            }

            var agendaCommand = new AgendaCommand(
                agenda.DataInicioDoAgendamento,
                agenda.ClienteId,
                agenda.FuncionarioId,
                agenda.TipoDeServicoId,
                agenda.EstabelecimentoId);

            agendaCommand.IdAgenda             = agenda.IdAgenda;
            agendaCommand.Status               = agenda.Status;
            agendaCommand.DataFimDoAgendamento = agenda.DataFimDoAgendamento;
            agendaCommand.Cliente              = ClienteAdapter.ToModelDomain(agenda.Cliente);
            agendaCommand.Funcionario          = FuncionarioAdapter.ToModelDomain(agenda.Funcionario);

            return(agendaCommand);
        }
Example #5
0
 public AgendaCommand Atualizar(AgendaCommand agendaCommand)
 {
     throw new NotImplementedException();
 }