Beispiel #1
0
        //Nesta classe implementaremos um ou mais metodos Handle.
        //O suficiente, neste caso, para criar um Plano ou editar e etc
        //
        public ICommandResult Handle(CreatePlanCommand command)
        {
            //TODO: No handle é feito todos os passos, validações

            //Validar se Plano já existe na base,código cnpb
            _planRepository.CheckPlan(command.Cnpb);
            //Criar VOs
            var name = new Name(command.NameField, command.Abreviation, command.Description);
            var date = new Date(command.Inclusion, command.Alteracion);
            //Criar Entidade
            var plan = new Plan();

            //Validar
            AddNotifications(name.Notifications);
            AddNotifications(date.Notifications);
            AddNotifications(plan.Notifications);
            if (Invalid)
            {
                return(null);
            }
            //Persistir o Plano
            _planRepository.Save(plan);
            //Enviar Email caso seja necessario
            //_emailService.Send();
            //Retornar o resultado para a tela
            return(new CreatePlanCommandResult());
        }