Beispiel #1
0
        /// <summary>
        /// Записывает в базу данных созданную задачу
        /// </summary>
        /// <param name="task"></param>
        public async Task CreateAsync(TaskDl task)
        {
            using IDbConnection db = Connection;
            db.Open();
            var lastID = await db.ExecuteScalarAsync(@"
            INSERT INTO Tasks 
            (UserID, TargetID, Name, StartDate, EndDate, Discription) 
            VALUES
            (@UserID, @TargetID, @Name, @StartDate, @EndDate, @Discription);
            SELECT SCOPE_IDENTITY();",
                                                     task);

            db.Close();
        }
Beispiel #2
0
        /// <summary>
        /// Обновляет в базе данных отредактированную задачу
        /// </summary>
        /// <param name="task"></param>
        public async Task UpdateAsync(TaskDl task)
        {
            using IDbConnection db = Connection;
            db.Open();
            await db.ExecuteAsync(@"
            UPDATE Tasks 
            SET 
            UserID = @UserID, 
            TargetID = @TargetID, 
            Name = @Name, 
            StartDate = @StartDate, 
            EndDate = @EndDate, 
            Discription = @Discription 
            WHERE ID = @ID",
                                  task);

            db.Close();
        }