Пример #1
0
        public async Task JournalTest()
        {
            using IDbConnection connection = new SqlConnection(DBConnection.connString);
            connection.Open();
            IDbTransaction transaction = connection.BeginTransaction();

            courseStorage     = new CourseStorage(connection, transaction);
            groupStorage      = new GroupStorage(connection, transaction);
            dictionaryStorage = new DictionaryStorage(connection, transaction);
            userStorage       = new UserStorage(connection, transaction);
            lessonStorage     = new LessonStorage(connection, transaction);

            try
            {
                await Setup();
                await TestSelects();
                await TestUpdate();

                foreach (Journal journalToDelete in listJournal)
                {
                    await TestEntityDelete(journalToDelete);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                transaction.Rollback();
            }
        }
Пример #2
0
        public void TimeTableTest()
        {
            using IDbConnection connection = new SqlConnection(DBConnection.connString);
            connection.Open();
            IDbTransaction transaction = connection.BeginTransaction();

            groupStorage  = new GroupStorage(connection, transaction);
            lessonStorage = new LessonStorage(connection, transaction);
            courseStorage = new CourseStorage(connection, transaction);

            try
            {
                Setup();
                TestSelects();
                TestUpdate();

                foreach (TimeTable timeTableToDelete in listTimetable)
                {
                    TestEntityDelete(timeTableToDelete);
                }

                ClearAllMocks();

                transaction.Commit();
            }
            catch
            {
                transaction.Rollback();
                throw new Exception();
            }
        }
Пример #3
0
        private void OpenLessons(object sender, RoutedEventArgs e)
        {
            var storage = new LessonStorage(Path.GetFullPath(AppResources.PathLessons),
                                            new XmlLesson(), this.username);

            ShowHideWait(new Explorer(storage));
        }
Пример #4
0
    public static bool CheckDateTimeForLessonWithId(string id)
    {
        if (CheckPlayerPrefsForLessonWithId(id) == false)
        {
            return(false);
        }
        string data = PlayerPrefs.GetString(id, null);

        if (data == null)
        {
            return(false);
        }
        BinaryFormatter bf         = new BinaryFormatter();
        MemoryStream    ms         = new MemoryStream(Convert.FromBase64String(data));
        LessonStorage   ls         = bf.Deserialize(ms) as LessonStorage;
        DateTime        lessonTime = ls.LessonDateTime;
        TimeSpan        ts         = DateTime.Now.Subtract(lessonTime);

        if (ts.TotalMinutes > 120f)
        {
            PlayerPrefs.DeleteKey(id);
            return(false);
        }
        return(true);
    }
Пример #5
0
        public async Task LessonTopicTest()
        {
            using IDbConnection connection = new SqlConnection(DBConnection.connString);
            connection.Open();
            IDbTransaction transaction = connection.BeginTransaction();

            courseStorage = new CourseStorage(connection, transaction);
            groupStorage  = new GroupStorage(connection, transaction);
            lessonStorage = new LessonStorage(connection, transaction);

            try
            {
                await Setup();
                await TestSelects();

                foreach (LessonTopic lessonTopicToDelete in listLessonTopic)
                {
                    await TestEntityDelete(lessonTopicToDelete);
                }
            }
            catch
            {
                throw new Exception();
            }
            finally
            {
                transaction.Rollback();
            }
        }
Пример #6
0
        public LessonController(IConfiguration Configuration)
        {
            string dbCon = Configuration.GetConnectionString("DefaultConnection");

            lessonStorage = new LessonStorage(dbCon);
            groupStorage  = new GroupStorage(dbCon);
            courseStorage = new CourseStorage(dbCon);
        }
Пример #7
0
    public static void SetPlayerPrefsForLessonWithId(string id, DateTime dateTime)
    {
        BinaryFormatter bf = new BinaryFormatter();
        MemoryStream    ms = new MemoryStream();
        LessonStorage   ls = new LessonStorage(id, dateTime);

        bf.Serialize(ms, ls as LessonStorage);
        PlayerPrefs.SetString(id, Convert.ToBase64String(ms.GetBuffer()));
    }