Пример #1
0
        public Tour FindByID(int itemId)
        {
            DbCommand command = database.CreateCommand(SQL_FIND_BY_ID);

            database.DefineParameter <int>(command, "@id", DbType.Int32, itemId);

            IEnumerable <Tour> tourList = QueryToursFromDatabase(command);

            return(tourList.FirstOrDefault());
        }
Пример #2
0
        public Log AddNewTourLog(Tour tour, string date, string report = "\"\"", int distance = 0, string duration = "\"\"",
                                 int rating     = 0, int steps = 0, float weightkg = 0, string bloodpreassure = "\"\"",
                                 string feeling = "\"\"", string weather = "\"\"")
        {
            DbCommand command = database.CreateCommand(SQL_INSERT_NEW_LOG);

            database.DefineParameter <int>(command, "@tourid", DbType.Int32, tour.ID);
            database.DefineParameter <string>(command, "@date", DbType.String, date);
            database.DefineParameter <string>(command, "@report", DbType.String, report);
            database.DefineParameter <int?>(command, "@distance", DbType.Int32, distance);
            database.DefineParameter <string>(command, "@duration", DbType.String, duration);
            database.DefineParameter <int?>(command, "@rating", DbType.Int32, rating);
            database.DefineParameter <int?>(command, "@steps", DbType.Int32, steps);
            database.DefineParameter <float?>(command, "@weightkg", DbType.Decimal, weightkg);
            database.DefineParameter <string>(command, "@bloodpreassure", DbType.String, bloodpreassure);
            database.DefineParameter <string>(command, "@feeling", DbType.String, feeling);
            database.DefineParameter <string>(command, "@weather", DbType.String, weather);

            return(FindById(database.ExecuteScalar(command)));
        }