Beispiel #1
0
        public void TestConvert_FromModelToEntity_TagIsCorrect()
        {
            // Prepare
            var model    = GenerateArticleTagModel();
            var expected = "Test Tag";

            // Act
            var actual = ArticleTagConverter.Convert(model).Tag;

            // Assert
            Assert.AreEqual(expected, actual);
        } // TEST METHOD ENDS
Beispiel #2
0
        public void TestConvert_FromEntityToModel_ArticleIdIsCorrect()
        {
            // Prepare
            var entity   = GenerateArticleTagEntity();
            var expected = Guid.Parse("cdfec528-a2a2-43b4-a310-5b1aab61e8da");

            // Act
            var actual = ArticleTagConverter.Convert(entity).ArticleId;

            // Assert
            Assert.AreEqual(expected, actual);
        } // TEST METHOD ENDS
Beispiel #3
0
        public void TestConvert_FromEntityToModel_TagIsCorrect()
        {
            // Prepare
            var entity   = GenerateArticleTagEntity();
            var expected = "Test Tag";

            // Act
            var actual = ArticleTagConverter.Convert(entity).Tag;

            // Assert
            Assert.AreEqual(expected, actual);
        } // TEST METHOD ENDS
Beispiel #4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 Business.Models.ArticleTag IModelService <Business.Models.ArticleTag, Guid> .Create(Business.Models.ArticleTag model)
 {
     try
     {
         this.database.Article_Tag.InsertOnSubmit(ArticleTagConverter.Convert(model));
         // Guardamos los cambios
         this.database.SubmitChanges();
         return(model);
     } // TRY ENDS
     catch (Exception e)
     {
         Console.Out.WriteLine(e.Message);
         Console.Out.WriteLine(e.StackTrace);
     } // CATCH ENDS
     return(null);
 }     // CREATE ENDS ------------------------------------------------------ //
Beispiel #5
0
        } // DELETE ENDS ------------------------------------------------------ //

        /// <summary>
        ///
        /// </summary>
        /// <param name="modelId"></param>
        /// <returns></returns>
        Business.Models.ArticleTag IModelService <Business.Models.ArticleTag, Guid> .Get(Guid modelId)
        {
            try
            {
                // Usamos una consulta LINQ para buscar el artículo en la base de datos
                var query = from articleTag in this.database.Article_Tag
                            where articleTag.ArticleId == modelId
                            select articleTag;

                // Si hay resultados, entonces buscamos el primero y lo devolvemos
                foreach (var result in query)
                {
                    return(ArticleTagConverter.Convert(result));
                } // FOREACH ENDS
            }     // TRY ENDS
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            } // CATCH ENDS
            return(null);
        }     // GET ENDS --------------------------------------------------------- //