Example #1
0
        public ActionResult CreatePrescriptionDetail(FormCollection collection)
        {
            try
            {
                var listNutraceuticals = _serviceNutraceutical.GetAllNutraceuticals();
                ViewBag.Nutraceuticals = listNutraceuticals;

                var prescription = new RegisterPrescriptionDetailCommand(collection["Dosage"], Convert.ToInt16(collection["Group"]), collection["Posology"],
                                                                         collection["Information"], collection["Note"], Guid.Parse(collection["PrescriptionId"]), Guid.Parse(collection["NutraceuticalId"]));

                _servicePrescription.RegisterPrescriptionDetail(prescription);

                return(RedirectToAction("CreatePrescriptionDetail/" + collection["PrescriptionId"]));
            }
            catch (Exception msg)
            {
                var mensagemError = msg.Message;
                return(View());
            }
        }
Example #2
0
        public PrescriptionDetail RegisterPrescriptionDetail(RegisterPrescriptionDetailCommand command)
        {
            // Cria a instâcia do usuário
            var domain = new PrescriptionDetail(command.Dosage, command.Group, command.Posology, command.Information, command.Note, command.PrescriptionId, command.NutraceuticalId);

            // Tenta ações e regras de negócio no domínio
            //domain.Register();

            // Salva as alterações da tabela no contexto do banco de dados
            _repository.SavePrescriptionDetail(domain);

            // Chama o commit
            if (Commit())
            {
                // Dispara o evento de usuário registrado
                DomainEvent.Raise(new OnPrescriptionDetailRegisteredEvent(domain));

                // Retorna o usuário
                return(domain);
            }

            // Se não comitou, retorna nulo
            return(null);
        }