public CommandResult Criar(CriarRotaCommand command) { try { command.Validate(); if (command.Invalid) { return(CommandResult.Invalid(command.Notifications.ToNotificationsString())); } Rota rota = Rota.Criar( DataString.FromString(command.Nome), DataString.FromNullableString(command.Composicao_Rota), DataString.FromNullableString(command.Observacao), command.Flag_Ativo); dataContext.Add(rota); dataContext.SaveChanges(); return(CommandResult.Valid()); } catch (Exception ex) { return(CommandResult.Invalid(ex.Message)); } }