Esempio n. 1
0
        public ActionResult Supprimer(int id)
        {
            ThemeServiceAPI rsa = new ThemeServiceAPI();
            ThemeDetails    r   = new ThemeDetails(rsa.Donner(id));

            return(View(r));
        }
Esempio n. 2
0
        public async Task <int> ThemeDetailsAddOrUpdate(ThemeDetails newThemeDetails)
        {
            string proc = SpName.ThemeDetailsInsert;

            if (newThemeDetails.Id.HasValue)
            {
                proc = SpName.ThemeDetailsUpdate;
            }

            try
            {
                var result = await connection.QueryAsync <decimal>(
                    proc,
                    new
                {
                    newThemeDetails.ProgramDetailId,
                    newThemeDetails.Topic
                },
                    dbTransaction,
                    commandType : CommandType.StoredProcedure
                    );

                return(decimal.ToInt32(result.FirstOrDefault()));
            }
            catch (SqlException ex)
            {
                Console.WriteLine(ex.Message);
                throw ex;
            }
        }
Esempio n. 3
0
 public static LessonTopicOutputModel ToOutputModel(ThemeDetails lessonTopic)
 {
     return(new LessonTopicOutputModel
     {
         Id = (int)lessonTopic.Id,
         Name = lessonTopic.Topic
     });
 }
Esempio n. 4
0
 public static TopicToTeachOutputModel ToOutputModel(ThemeDetails topic)
 {
     return(new TopicToTeachOutputModel
     {
         ProgramDetailId = (int)topic.ProgramDetailId,
         Topic = topic.Topic
     });
 }
Esempio n. 5
0
        public ActionResult Details(int id)
        {
            ThemeServiceAPI rsa = new ThemeServiceAPI();
            Theme           r   = rsa.Donner(id);
            ThemeDetails    rd  = new ThemeDetails(r);

            return(View(rd));
        }
Esempio n. 6
0
        private async void TestEntityDelete(ThemeDetails ThemeDetailsToDelete)
        {
            List <ThemeDetails> actualThemes = await courseStorage.ThemeDetailsGetAll();

            await courseStorage.ThemeDetailsDeleteById((int)ThemeDetailsToDelete.Id);

            List <ThemeDetails> actualThemesAfterDelete = await courseStorage.ThemeDetailsGetAll();

            Assert.AreEqual(actualThemes.Count - 1, actualThemesAfterDelete.Count);
        }
Esempio n. 7
0
 public static Theme VersTheme(this ThemeDetails e)
 {
     if (e == null)
     {
         return(null);
     }
     return(new Theme {
         id = e.id, actif = e.actif, description = e.description, titre = e.titre
     });
 }
Esempio n. 8
0
 public ActionResult Supprimer(int id, ThemeDetails r)
 {
     if (ModelState.IsValid)
     {
         ThemeServiceAPI rsa = new ThemeServiceAPI();
         bool            b   = rsa.Supprimer(id);
         if (b)
         {
             return(RedirectToAction("Index"));
         }
     }
     return(View(r));
 }
Esempio n. 9
0
        private async void TestSelects()
        {
            List <ThemeDetails> actualThemes = await courseStorage.ThemeDetailsGetAll();

            for (int i = 0; i < themeDetailsList.Count; i++)
            {
                ThemeDetails theme34 = themeDetailsList[i];

                Assert.Contains(theme34, actualThemes);
            }
            ThemeDetails theme = await courseStorage.ThemeDetailsGetById((int)themeDetailsList[0].Id);

            Assert.AreEqual(themeDetailsList[0], theme);
        }
        public void Should_have_validation_error_when_folder_is_empty()
        {
            var command = new ThemeDetails
            {
                Id          = Guid.NewGuid(),
                Name        = "Name",
                Description = "Description",
                Folder      = string.Empty
            };

            var themeRulesMock = new Mock <IThemeRules>();
            var validator      = new ThemeDetailsValidator <ThemeDetails>(themeRulesMock.Object);

            validator.ShouldHaveValidationErrorFor(x => x.Folder, command);
        }
Esempio n. 11
0
        private async void TestUpdate()
        {
            themeDetailsList[0].ProgramDetailId = 3;
            themeDetailsList[0].Topic           = "Kjgeir";

            await courseStorage.ThemeDetailsAddOrUpdate(themeDetailsList[0]);

            ThemeDetails theme1 = await courseStorage.ThemeDetailsGetById((int)themeDetailsList[0].Id);

            Assert.AreEqual(themeDetailsList[0], theme1);

            ThemeDetails theme2 = await courseStorage.ThemeDetailsGetById((int)themeDetailsList[3].Id);

            Assert.AreEqual(themeDetailsList[3], theme2);
        }
Esempio n. 12
0
        public async Task <ActionResult <int> > UpdateThemeDetails([FromBody] ThemeDetails themeDetails)
        {
            if (themeDetails == null)
            {
                return(BadRequest("Model is null"));
            }

            var result = await courseStorage.ThemeDetailsAddOrUpdate(themeDetails);

            if (result.Equals(null))
            {
                return(BadRequest("Failed"));
            }

            return(Ok(result));
        }
        public void Should_have_validation_error_when_theme_name_is_not_unique()
        {
            var command = new ThemeDetails
            {
                Id          = Guid.NewGuid(),
                Name        = "Name",
                Description = "Description",
                Folder      = "folder"
            };

            var themeRulesMock = new Mock <IThemeRules>();

            themeRulesMock.Setup(x => x.IsThemeNameUnique(command.Name, Guid.Empty)).Returns(false);

            var validator = new ThemeDetailsValidator <ThemeDetails>(themeRulesMock.Object);

            validator.ShouldHaveValidationErrorFor(x => x.Name, command);
        }
        public void Should_have_validation_error_when_folder_is_not_valid()
        {
            var command = new ThemeDetails
            {
                Id          = Guid.NewGuid(),
                Name        = "Name",
                Description = "Description",
                Folder      = "a@b"
            };

            var themeRulesMock = new Mock <IThemeRules>();

            themeRulesMock.Setup(x => x.IsThemeFolderValid(command.Description)).Returns(false);

            var validator = new ThemeDetailsValidator <ThemeDetails>(themeRulesMock.Object);

            validator.ShouldHaveValidationErrorFor(x => x.Folder, command);
        }
        public void Should_have_validation_error_when_description_is_too_long()
        {
            var description = "";

            for (int i = 0; i < 251; i++)
            {
                description += i;
            }

            var command = new ThemeDetails
            {
                Id          = Guid.NewGuid(),
                Name        = "Name",
                Description = description,
                Folder      = "folder"
            };

            var themeRulesMock = new Mock <IThemeRules>();
            var validator      = new ThemeDetailsValidator <ThemeDetails>(themeRulesMock.Object);

            validator.ShouldHaveValidationErrorFor(x => x.Description, command);
        }