Beispiel #1
0
        public static void Main()
        {
            var db = new ApplicationDbContext();
            var repo = new DbRepository<JokeCategory>(db);
            var categoriesService = new CategoriesService(repo);

            var configuration = Configuration.Default.WithDefaultLoader();
            var browsingContext = BrowsingContext.New(configuration);

            for (int i = 1; i <= 10000; i++)
            {
                var url = $"http://vicove.com/vic-{i}";
                var document = browsingContext.OpenAsync(url).Result;
                var jokeContent = document.QuerySelector("#content_box .post-content").TextContent.Trim();
                if (!string.IsNullOrWhiteSpace(jokeContent))
                {
                    var categoryName = document.QuerySelector("#content_box .thecategory a").TextContent.Trim();
                    var category = categoriesService.EnsureCategory(categoryName);
                    var joke = new Joke { Category = category, Content = jokeContent };
                    db.Jokes.Add(joke);
                    db.SaveChanges();
                    Console.WriteLine(i);
                }
            }
        }
Beispiel #2
0
        //[Test]
        public void ConsultaTodosOsProdutos()
        {
            Joke<ProdutoTeste> targetTeste = new Joke<ProdutoTeste>();
            List<ProdutoTeste> produtos = targetTeste.GetAll();

            Assert.That(produtos.Count, Is.EqualTo(11088));
        }
Beispiel #3
0
        //[Test]
        public void ConsultaTodasAsCategoriasPrincipais()
        {
            Joke<CategoriaTeste> targetTeste = new Joke<CategoriaTeste>();
            List<CategoriaTeste> produtos = targetTeste.Query()
                .Where("id_categoria_teste = 0").Execute();

            Assert.That(produtos.Count, Is.EqualTo(27));
        }
Beispiel #4
0
        internal void CarregaSubCategorias()
        {
            var sql = new Joke<CategoriaTeste>().Query()
                .Where("categoriaTeste.IdCategoriaTeste = " + Id);

            var lis = sql.Execute();
            subCategorias = lis;
        }
Beispiel #5
0
        public int AddJoke(string mText, int mMemberID)
        {
            NokatEntities entities = new NokatEntities();
            Joke _Jok = new Joke { JokeText = mText, MemberID = mMemberID,TimeAdded=DateTime.Now.ToUniversalTime() , Rank = 0 , Good= 0 , Bad = 0 };
            entities.Jokes.AddObject(_Jok);

            entities.SaveChanges();
            return _Jok.ID;
        }
Beispiel #6
0
        //[Test]
        public void ConsultaCategoriaPorNome()
        {
            Joke<CategoriaTeste> targetTeste = new Joke<CategoriaTeste>();
            List<CategoriaTeste> produtos = targetTeste.Query()
                .Where("categoriaTeste.Nome = 'Arroz, Massas e Pratos Prontos'")
                .Execute();

            Assert.That(produtos.Count, Is.EqualTo(1));
        }
Beispiel #7
0
 static DemoServiceImpl()
 {
     m_dict = new Dictionary<string, State?>();
     m_jokes = new List<Joke>();
     m_jokes.Add(new Joke() { Question = "Why did the chicken code in VBScript?", Answer = "His head was cut off.", DateAdded = DateTime.Now });
     m_jokes.Add(new Joke() { Question = "How many VBScript programmers does it take to screw in a light bulb?", Answer = "Three. One IsObject, one IsArray, and one to figure out the difference.", DateAdded = DateTime.Now });
     m_jokes.Add(new Joke() { Question = "What is the keyword \"set\" for?", Answer = "The code wasn't unreliable enough without the extra keyword.", DateAdded = DateTime.Now });
     s_status = new Joke() { Question = "Status?", Answer = "Foo: RequestId: ", DateAdded = DateTime.Now };
     m_jokes.Add(s_status);
 }
Beispiel #8
0
        //[Test]
        public void ConsultaProdutosPorId()
        {
            Joke<ProdutoTeste> targetTeste = new Joke<ProdutoTeste>();

            List<ProdutoTeste> produtos = targetTeste.Query()
                .Where("produtoTeste.Id <= 10")
                .Execute();

            Assert.That(produtos.Count, Is.EqualTo(10));
        }
 public void SetUp()
 {
     DictionaryEntitiesMap.INSTANCE.TryAddEntity(typeof(CategoriaTeste));
     DictionaryEntitiesMap.INSTANCE.TryAddEntity(typeof(Ags));
     target = new Joke<CategoriaTeste>();
     JokeConfigurationBuilder.NewConfigurationToPostgreSQL()
         .Host(LOCAL_HOST)
         .Port(PORTA_5432)
         .Username(USER)
         .Password(SENHA)
         .DataBase(JOKE_BD)
         .BuildConfiguration();
 }
Beispiel #10
0
 public bool delJoke(string usuw)
 {
     if (usuw == null)
     {
         return(false);
     }
     else
     {
         int  usuwID  = int.Parse(usuw);
         Joke usuwany = this.x.GetByID(usuwID);
         this.x.Delete(usuwany);
         x.Commit();
         return(true);
     }
 }
        public async Task <ActionResult> Post([FromBody] Joke joke)
        {
            if (AuthorizationUtils.Authorized(Request, _config) == false)
            {
                return(Unauthorized());
            }
            if (joke == null || String.IsNullOrEmpty(joke.JokeText))
            {
                return(BadRequest());
            }

            var j = await _data.Add(joke);

            return(Ok());
        }
Beispiel #12
0
        private Joke SetValue(Joke x)
        {
            int CatId = Convert.ToInt32(ddlCat.SelectedValue);

            x.id          = Convert.ToInt32(hdnID.Value);
            x.title       = txtJokeTitle.Text;
            x.category_id = CatId;
            x.teaser      = txtTeaser.Text;
            x.joke_text   = txtJoke.Text;
            x.featured    = chkFeatured.Checked;
            x.created_at  = Convert.ToDateTime(hdnCreatedAt.Value);
            x.user_id     = Convert.ToInt32(hdnUID.Value);

            return(x);
        }
        public override async void Execute(Message message, TelegramBotClient client)
        {
            var chatId    = message.Chat.Id;
            var MessageId = message.MessageId;

            var Restclient = new RestClient("https://joke3.p.rapidapi.com/v1/joke?nsfw=false");
            var request    = new RestRequest(Method.GET);

            request.AddHeader("x-rapidapi-key", "6b0338b559msh0f5b4fae99c205cp1b304cjsn93f7f906d12b");
            request.AddHeader("x-rapidapi-host", "joke3.p.rapidapi.com");
            IRestResponse response = Restclient.Execute(request);
            Joke          joke     = JsonConvert.DeserializeObject <Joke>(response.Content);

            await client.SendTextMessageAsync(chatId, joke.Content, replyToMessageId : MessageId);
        }
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Joke = await _context.Joke.FirstOrDefaultAsync(m => m.ID == id);

            if (Joke == null)
            {
                return(NotFound());
            }
            return(Page());
        }
        public ServiceResponse AddJoke(JokeFromApiModel model)
        {
            var count = jokesCollection.CountDocuments(new BsonDocument());
            var joke  = new Joke()
            {
                JokeId      = count + 1,
                AddedDate   = DateTime.Now,
                Description = model.Description,
                Content     = model.Content
            };

            redisDb.SortedSetAdd(keys, joke.JokeId.ToString(), 0);
            jokesCollection.InsertOne(joke);
            return(new ServiceResponse());
        }
Beispiel #16
0
        /// <summary>
        /// Code here
        /// </summary>
        /// <param name="serviceProvider"></param>
        private static void SandboxCode(IServiceProvider serviceProvider)
        {
            //var db = serviceProvider.GetService<FunAppContext>();
            //Console.WriteLine(db.Users.Count());

            var context = serviceProvider.GetService <FunAppContext>();

            Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
            var parser    = new HtmlParser();
            var webClient = new WebClient
            {
                Encoding = Encoding.GetEncoding("windows-1251"),
            };

            for (var i = 201; i < 3287; i++)
            {
                var url          = "http://fun.dir.bg/vic_open.php?id=" + i;
                var html         = webClient.DownloadString(url);
                var document     = parser.Parse(html);
                var jokeContent  = document.QuerySelector("#newsbody")?.TextContent?.Trim();
                var categoryName = document.QuerySelector(".tag-links-left a")?.TextContent?.Trim();

                if (!string.IsNullOrWhiteSpace(jokeContent) &&
                    !string.IsNullOrWhiteSpace(categoryName))
                {
                    var category = context.Categories.FirstOrDefault(x => x.Name == categoryName);

                    if (category == null)
                    {
                        category = new Category
                        {
                            Name = categoryName,
                        };
                    }

                    var joke = new Joke()
                    {
                        Category = category,
                        Content  = jokeContent,
                    };

                    context.Jokes.Add(joke);
                    context.SaveChanges();
                }

                Console.WriteLine($"{i} => {categoryName}");
            }
        }
Beispiel #17
0
        async void DelayForFive()
        {
            Joke j  = new Joke();
            Joke j2 = new Joke();

            string              path     = "https://jokesapi.gottacatchemall.repl.co/jokes";
            HttpClient          client   = new HttpClient();
            HttpResponseMessage response = await client.GetAsync(path);

            if (response.IsSuccessStatusCode)
            {
                dynamic jsonJoke = await response.Content.ReadAsStringAsync();

                j = JsonConvert.DeserializeObject <Joke>(jsonJoke);
            }
            HttpResponseMessage response2 = await client.GetAsync(path);

            if (response.IsSuccessStatusCode)
            {
                dynamic jsonJoke = await response2.Content.ReadAsStringAsync();

                j2 = JsonConvert.DeserializeObject <Joke>(jsonJoke);
            }

            await Task.Delay(new TimeSpan(0, 30, 30)).ContinueWith(o =>
            {
                TextNotification n = new TextNotification();
                n.Show();
            });

            await Task.Delay(new TimeSpan(3, 0, 160)).ContinueWith(o =>
            {
                Notification n = new Notification();
                n.Show();
            });

            await Task.Delay(new TimeSpan(6, 30, 160)).ContinueWith(o =>
            {
                TextNotification n = new TextNotification();
                n.Show();
            });

            await Task.Delay(new TimeSpan(8, 30, 160)).ContinueWith(o =>
            {
                Notification n = new Notification();
                n.Show();
            });
        }
Beispiel #18
0
        public void AddJoke(Guid gameId, UpsertJokeDTO dto)
        {
            var game = this.gameRepository.GetById(gameId);

            var joke = new Joke()
            {
                Author  = dto.Author,
                Content = dto.Content,
                Created = DateTime.Now,
                Number  = dto.Number
            };

            game.Jokes ??= new List <Joke>();
            game.Jokes.Add(joke);
            this.gameRepository.Update(game);
        }
Beispiel #19
0
        public async Task <Joke> GetDadJoke()
        {
            Joke       joke   = new Joke();
            HttpClient client = new HttpClient();

            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            var content = await client.GetStringAsync("https://icanhazdadjoke.com/");

            JObject jsonContent = JObject.Parse(content);

            joke.ID          = jsonContent["id"].ToString();
            joke.JokeContent = jsonContent["joke"].ToString();
            joke.Votes       = 0;
            joke.Type        = true;
            return(joke);
        }
Beispiel #20
0
        public async Task <Joke> GetCNJoke()
        {
            Joke       joke   = new Joke();
            HttpClient client = new HttpClient();

            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            var content = await client.GetStringAsync("https://api.chucknorris.io/jokes/random");

            JObject jsonContent = JObject.Parse(content);

            joke.ID          = jsonContent["id"].ToString();
            joke.JokeContent = jsonContent["value"].ToString();
            joke.Votes       = 0;
            joke.Type        = false;
            return(joke);
        }
Beispiel #21
0
    /// <summary>
    /// Sets te joke linked to this card
    /// </summary>
    /// <param name="joke">The joke object linked to the card</param>
    /// <param name="punchline">Is this card showing the punchline? (If false, it shows the setup)</param>
    internal void SetJoke(Joke joke, bool punchline)
    {
        _joke        = joke;
        _isPunchline = punchline;

        // set display text - punchline or setup?
        var stringToUse = punchline ? joke.Punchline : joke.Setup;

        JokeText.text = TextFormatter.GetCardJokeString(stringToUse);

        // set the images
        var imageIndex = IsPunchline() ? 1 : 0;

        CardBack.GetComponent <SpriteRenderer>().sprite  = PunchlineBlingController.Instance.CardBacks[imageIndex];
        CardFront.GetComponent <SpriteRenderer>().sprite = PunchlineBlingController.Instance.CardFronts[imageIndex];
    }
Beispiel #22
0
 public ActionResult Put(int id, [FromBody] Joke joke)
 {
     try
     {
         RestDatabaseContext db = new RestDatabaseContext();
         Joke findJoke          = db.Jokes.First(item => item.Id == id);
         findJoke.Rating = joke.Rating;
         findJoke.Text   = joke.Text;
         db.SaveChanges();
         return(Ok(findJoke));
     }
     catch (Exception e)
     {
         return(StatusCode(StatusCodes.Status500InternalServerError, e.Message));
     }
 }
Beispiel #23
0
        public static async Task SayJoke()
        {
            Joke joke = DataAccess.DeserializeModuleData(typeof(Joke), await DataAccess.GetModuleData(Modules.JOKE));

            StringBuilder jokeString = new StringBuilder();

            jokeString.Append("Lückenfüller Lückenfüller <break time='300ms'/>");
            jokeString.AppendLine($"Einen {joke.Title.Remove(joke.Title.Length - 1)} gefällig: <break time='300ms'/><prosody rate=\"-15%\">{joke.Description}</prosody>");

            await sayAsync(jokeString.ToString());

            // Neuen Joke laden
            #pragma warning disable 4014
            DataAccess.AddOrReplaceModuleData(Modules.JOKE, await JokeHelper.GetJoke());
            #pragma warning restore 4014
        }
Beispiel #24
0
        public ActionResult Delete(int id)
        {
            try
            {
                RestDatabaseContext db = new RestDatabaseContext();
                Joke findJoke          = db.Jokes.First(item => item.Id == id);
                db.Jokes.Remove(findJoke);
                db.SaveChanges();

                return(Ok(id));
            }
            catch (Exception e)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, e.Message));
            }
        }
 public async Task PutAsync(Guid id, [FromBody] Joke joke)
 {
     try
     {
         //there are several approaches here
         //one would be to eliminate the id and use the one on the joke
         //another would be to query the database for the expected joke confirm there are changes
         //I've chosen to simply update the joke for brevity process the update
         Validate(joke);
         await this.JokeService.UpdateAsync(joke);
     }
     catch (Exception ex)
     {
         this._logger.LogError(ex.StackTrace);
         throw new Exception(ex.Message);
     }
 }
Beispiel #26
0
    public Joke GetRandomJoke()
    {
        Joke result = null;

        var unused = Jokes.Where(j => !j.Found).ToList();

        var randomIndex = Random.Range(0, unused.Count);

        result       = unused[randomIndex];
        result.Found = true;

        FlowchartScript.ExecuteBlock(result.Name);

        print(result.Name);

        return(result);
    }
Beispiel #27
0
        static async Task Main(string[] args)
        {
            ChuckNorrisApi api = new ChuckNorrisApi();

            try
            {
                Console.WriteLine("Getting random joke:");
                Joke joke = await api.GetRandomJoke();

                PrintProperties <Joke>(joke);

                Console.WriteLine("Getting random joke from a set of categories:");
                Joke jokeFromCategory = await api.GetRandomJoke(new string[] { "dev", "music" });

                PrintProperties <Joke>(jokeFromCategory);

                Console.WriteLine("Getting random personalized joke:");
                Joke personalizedJoke = await api.GetRandomJoke("Peter");

                PrintProperties <Joke>(personalizedJoke);

                Console.WriteLine("Getting random personalized joke from a set of categories:");
                Joke personalizedJokeFromCategory = await api.GetRandomJoke("Peter", new string[] { "dev", "music" });

                PrintProperties <Joke>(personalizedJokeFromCategory);

                Console.WriteLine("Getting categories:");
                string[] categories = await api.GetCategories();

                Console.WriteLine(string.Join(",", categories));

                Console.WriteLine("Getting all jokes containing a particular word or phrase:");
                List <Joke> searchResults = await api.SearchForText("films");

                foreach (Joke result in searchResults)
                {
                    PrintProperties <Joke>(result);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }

            api.Dispose();
        }
Beispiel #28
0
        public void httpRequest(string URL)
        {
            WebRequest  request  = WebRequest.Create(URL);
            WebResponse response = request.GetResponse();
            Joke        joke     = new Joke();

            // Convert the stream to a string
            using (Stream dataStream = response.GetResponseStream())
                using (StreamReader sr = new StreamReader(dataStream))
                    using (JsonReader reader = new JsonTextReader(sr))
                    {
                        // Deserialize the string into an object of the Joke class
                        JsonSerializer ser = new JsonSerializer();
                        while (reader.Read())
                        {
                            if (reader.TokenType == JsonToken.StartObject)
                            {
                                joke = ser.Deserialize <Joke>(reader);
                            }
                        }

                        if (joke.type == "single")
                        {
                            // If type == "single", the joke only has the "joke" property
                            if (joke.joke == string.Empty)
                            {
                                output.Text = "No jokes found";
                            }
                            output.Text = joke.joke;
                        }
                        else
                        {
                            // If type == "twopart", the joke has the "setup" and "delivery" properties
                            if (joke.setup == string.Empty && joke.delivery == string.Empty)
                            {
                                output.Text = "No jokes found";
                            }
                            output.Text = joke.setup;

                            output.Text += "\n" + joke.delivery;
                        }
                    }

            // Close the request
            response.Close();
        }
        public async Task <RuntimeResult> AddJokeAsync([Remainder] string jokeText)
        {
            if (jokeText is null)
            {
                return(new ErrorResult("Joke is empty"));
            }

            Joke joke = new Joke
            {
                Text = jokeText,
                User = User
            };

            await Database.Jokes.AddAsync(joke);

            return(new SuccessResult());
        }
        //[Test]
        public void TestB()
        {
            GgsTeste cat = new GgsTeste();
            cat.Nome = "Teste Insert 4";

            var insert = new CommandInsertGenerator(cat).GetCommand();

            NonQueryCommandsExecutor executor = new NonQueryCommandsExecutor(cat);
            executor.Execute();

            var novaCategoria = new Joke<GgsTeste>().Query()
                .Where("nome ILIKE 'Teste%4'")
                .Execute()[0];

            Assert.That(novaCategoria.Id, Is.EqualTo(23));
            Assert.That(novaCategoria.Nome, Is.EqualTo("Teste Insert 4"));
        }
Beispiel #31
0
        static void Main()
        {
            // TODO: Add DI container an AutoMapper
            var db                = new ApplicationDbContext();
            var dbRopository      = new DbRepository <JokeCategory>(db);
            var categoryesService = new CategoriesService(dbRopository);

            // AngleSharp configurations
            IConfiguration   configuration     = Configuration.Default.WithDefaultLoader();
            IBrowsingContext browsingContex    = BrowsingContext.New(configuration);
            long             countOfAddedJokes = 0;

            for (int i = 1; i < 65000; i++)
            {
                string    url          = $"http://vicove.com/vic-{i}";
                IDocument document     = browsingContex.OpenAsync(url).Result;
                string    jokeContent  = document.QuerySelector("#content_box .post-content p").TextContent.Trim();
                string    categoryName = document.QuerySelector("#content_box .thecategory a").TextContent.Trim();

                bool isValidJoke     = !string.IsNullOrWhiteSpace(jokeContent);
                bool isValidCategory = !string.IsNullOrWhiteSpace(categoryName);

                if (isValidJoke && isValidCategory)
                {
                    countOfAddedJokes++;

                    JokeCategory category = categoryesService.EnsureCategory(categoryName);
                    Joke         joke     = new Joke
                    {
                        Content  = jokeContent,
                        Category = category
                    };

                    db.Jokes.Add(joke);
                    db.SaveChanges();

                    if (countOfAddedJokes % 100 == 0)
                    {
                        Console.WriteLine($"Added {countOfAddedJokes} jokes");
                    }
                }
            }

            Console.WriteLine();
            Console.WriteLine($"--- DONE => {countOfAddedJokes} joke added");
        }
Beispiel #32
0
        /// <summary>
        /// Pulls a random joke from the database and returns it
        /// </summary>
        /// <returns></returns>
        public static Joke QueryRandomJoke()
        {
            Joke joke = null;

            using (SqliteConnection connection = OpenDatabase())
            {
                using (SqliteCommand command = connection.CreateCommand())
                {
                    command.CommandText = "SELECT * FROM TJokes WHERE jokeID IN (SELECT jokeID FROM TJokes ORDER BY RANDOM() LIMIT 1)";
                    SqliteDataReader reader = command.ExecuteReader();
                    reader.Read();
                    joke = Joke.FromDataRow(reader);
                    reader.Close();
                }
            }
            return(joke);
        }
Beispiel #33
0
        public void ReplaceWith_DoesNotMatch_DoesNotReplace()
        {
            // Setup Fake Data
            var joke = new Joke {
                Value = "Some joke"
            };
            var userName = new UserName {
                Name = "John", Surname = "Doe"
            };

            // Execute Test
            var result = joke.ReplaceWith(userName);

            // Verify mocks and assertions
            Assert.IsNotNull(result);
            Assert.AreEqual(joke.Value, result.Value);
        }
Beispiel #34
0
        public NewItemPage()
        {
            InitializeComponent();

            //Item = new Item
            //{
            //	Text = "Item name",
            //	Description = "This is a nice description"
            //};

            Joke = new Joke
            {
                Text = ""
            };

            BindingContext = this;
        }
Beispiel #35
0
        /// <summary>Replaces the with.</summary>
        /// <param name="joke">The joke.</param>
        /// <param name="userName">Name of the user.</param>
        /// <returns>The joke with replaced name and surname.</returns>
        /// <exception cref="ArgumentNullException">joke
        /// or
        /// userName</exception>
        public static Joke ReplaceWith(this Joke joke, UserName userName)
        {
            if (joke == null)
            {
                throw new ArgumentNullException(nameof(joke));
            }

            if (userName == null)
            {
                throw new ArgumentNullException(nameof(userName));
            }

            joke.Value = joke.Value.Replace(Chuck, userName.Name);
            joke.Value = joke.Value.Replace(Norris, userName.Surname);

            return(joke);
        }
Beispiel #36
0
        public RedirectToActionResult JokeForm(string name,
                                               string keyword, string jokeline)
        {
            if (ModelState.IsValid)
            {
                Joke joke = new Joke {
                    KeyWord = keyword
                };
                joke.Name     = name;
                joke.JokeLine = jokeline;

                /*joke.Joke.Add(new Joke() { Name = name });
                 * joke.PubDate = DateTime.Parse(pubDate);*/
                repo.AddJoke(joke);  // this is temporary, in the future the data will go in a database
            }
            return(RedirectToAction("Jokespage"));
        }
Beispiel #37
0
        // Get random joke from a specific Chuck Norris API
        public static string GetJokeFromCategory(string category)
        {
            Joke   joke = new Joke();
            string Url  = "https://api.chucknorris.io/jokes/random?category=" + category;

            try
            {
                string stringResult = HttpWebRequest("GET", Url);
                joke = JsonConvert.DeserializeObject <Joke>(stringResult);

                return(joke.Value);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Beispiel #38
0
        public IActionResult Get()
        {
            var jokes = new Joke[]
            {
                new Joke()
                {
                    Question = "What do you call a boomerang that won't come back?",
                    Answer   = "A stick"
                },
                new Joke()
                {
                    Question = "What horse never comes out in the daytime?",
                    Answer   = "A night mare"
                }
            };

            return(Ok(jokes));
        }
Beispiel #39
0
        public async Task <Joke> GetJokeAsync()
        {
            Joke joke = null;

            client.BaseAddress = new Uri(url);
            client.DefaultRequestHeaders.Accept.Add(
                new MediaTypeWithQualityHeaderValue("application/json"));


            HttpResponseMessage response = await client.GetAsync(url);

            if (response.IsSuccessStatusCode)
            {
                joke = await response.Content.ReadAsAsync <Joke>();
            }

            return(joke);
        }
Beispiel #40
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            try
            {
                Joke jokeOBJ = Factory.CreateJoke();
                CUD.AddJoke(AssignValues(jokeOBJ));

                alertexit1.Checked   = false;
                alertexit2.Checked   = true;
                SysMessage.InnerText = "Joke creation successful!";
            } catch (Exception ex)
            {
                alertexit1.Checked      = true;
                alertexit2.Checked      = false;
                SysMessageErr.InnerText = "Joke creation failed";
                SysDetails.InnerText    = ex.Message;
            }
        }
Beispiel #41
0
        //[Test]
        public void TodosProdutosMySQL()
        {
            JokeConfigurationBuilder.NewConfigurationToMySQL()
                .Host("mysql01.ggs5.hospedagemdesites.ws")
                .Username("ggs5")
                .Password("desenv_1")
                .DataBase("ggs5")
                .BuildConfiguration();

            Joke<ProdutoTeste> targetTeste = new Joke<ProdutoTeste>();
            List<ProdutoTeste> produtos = targetTeste.GetAll();

            Assert.That(produtos.Count, Is.EqualTo(3));
        }
        //[Test]
        public void TestC()
        {
            GgsTeste cat = new GgsTeste();
            cat.Nome = "Gui";

            Ags ags = new Ags();
            ags.Nome = "Alana";
            ags.Ggs = cat;

            NonQueryCommandsExecutor executor = new NonQueryCommandsExecutor(ags);
            executor.Execute();

            var novaCategoria = new Joke<Ags>().Query()
                .Where("ags.Ggs.Nome ILIKE 'Gui'")
                .Execute()[0];

            Assert.That(novaCategoria.Id, Is.EqualTo(14));
            Assert.That(novaCategoria.Nome, Is.EqualTo("Gui"));
        }
Beispiel #43
0
 public Task AddJokeAsync(Joke joke)
 {
     return Task.Run(() => {m_jokes.Add(joke); });
 }
Beispiel #44
0
 public void SetUp()
 {
     new Joke<Ags>();
     target = new Joke<Produto>();
     JokeConfigurationBuilder.NewConfigurationToPostgreSQL()
         .Host(LOCAL_HOST)
         .Port(PORTA_5432)
         .Username(USER)
         .Password(SENHA)
         .DataBase(JOKE_BD)
         .BuildConfiguration();
 }
Beispiel #45
0
 /// <summary>
 /// Add a joke
 /// </summary>
 /// <param name="joke"> A nice work-friendly joke</param>
 public Task AddJokeAsync(Joke joke)
 {
     return SendAsync("AddJoke", new Dictionary<string, object>() { {"joke", joke } });
 }
Beispiel #46
0
 /// <summary>
 /// Add a joke
 /// </summary>
 /// <param name="joke"> A nice work-friendly joke</param>
 public void AddJoke(Joke joke)
 {
     Send("AddJoke", new Dictionary<string, object>() { {"joke", joke } });
 }