/// <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(); }
/// <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(); }