Beispiel #1
0
        private void AttestationThemeTestSelects()
        {
            List <AttestationTheme> listActual = dictionaryStorage.AttestationThemeGetAll().Result;

            for (int i = 0; i < listAttestationTheme.Count; i++)
            {
                Assert.Contains(listAttestationTheme[i], listActual);
            }

            AttestationTheme actualAttestationTheme = dictionaryStorage.AttestationThemeGetByID((int)listAttestationTheme[0].Id).Result;

            Assert.AreEqual(listAttestationTheme[0], actualAttestationTheme);
        }
Beispiel #2
0
 private void AttestationThemeSetup()
 {
     foreach (AttestationTheme item in DictionaryMocks.AttestationThemeMocks)
     {
         AttestationTheme newAttestationTheme = (AttestationTheme)item.Clone();
         newAttestationTheme.Id = null;
         listAttestationTheme.Add(newAttestationTheme);
     }
     for (int i = 0; i < listAttestationTheme.Count; i++)
     {
         int id = (int)dictionaryStorage.AttestationThemeAddOrUpdate(listAttestationTheme[i]).Result;
         listAttestationTheme[i].Id = id;
     }
 }
Beispiel #3
0
        private async Task AttestationThemeTestUpdate()
        {
            AttestationTheme attestationTheme = listAttestationTheme[0];

            attestationTheme.Theme = "Вышивание крестиком";
            await dictionaryStorage.AttestationThemeAddOrUpdate(attestationTheme);

            AttestationTheme attestationTheme1 = dictionaryStorage.AttestationThemeGetByID((int)attestationTheme.Id).Result;

            Assert.AreEqual(attestationTheme, attestationTheme1);

            AttestationTheme attestationTheme2 = dictionaryStorage.AttestationThemeGetByID((int)listAttestationTheme[1].Id).Result;

            Assert.AreEqual(listAttestationTheme[1], attestationTheme2);
        }
Beispiel #4
0
        public async Task <int?> AttestationThemeAddOrUpdate(AttestationTheme model)
        {
            {
                try
                {
                    if (model.Id.HasValue)
                    {
                        var result = await connection.QueryAsync <int>(
                            SpName.AttestationThemeUpdate,
                            new
                        {
                            model.Id,
                            model.CourseId,
                            model.Theme
                        },
                            dbTransaction,
                            commandType : CommandType.StoredProcedure);

                        return(result.FirstOrDefault());
                    }
                    else
                    {
                        var result = await connection.QueryAsync <int>(
                            SpName.AttestationThemeInsert,
                            new
                        {
                            model.CourseId,
                            model.Theme
                        },
                            dbTransaction,
                            commandType : CommandType.StoredProcedure);

                        return(result.FirstOrDefault());
                    }
                }
                catch (SqlException ex)
                {
                    Console.WriteLine(ex.Message);
                    throw ex;
                }
            }
        }